Copying cells with any text value.

JLGUZMAN

New Member
Joined
Jun 15, 2018
Messages
8
Hello,

I am trying to write into my code that if a cell in therange I am searching has any text to select it for copying. I am using the.TEXT function and the wildcard is not working as a part of the code. Howshould I be putting it. Here is the code I have not:





Sub Sort_Deployed()



a = Worksheets("Master").Cells(Rows.Count,18).End(xlUp).Row

For i = 2 To a



IfWorksheets("Master").Cells(i, 18).Text = “*” Then


Worksheets("Master").Rows(i).Copy

Worksheets("Deployed").Activate

b =Worksheets("Deployed").Cells(Rows.Count, 18).End(xlUp).Row

Worksheets("Deployed").Cells(b + 1, 1).Select

ActiveSheet.Paste

Worksheets("Master").Activate

End If

Next

Application.CutCopyMode = False

End Sub


 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
What happens if the cell in column R has a number instead of text?
 
Upvote 0
If you mean that you want to copy the cell if it contains a value (numeric or text), and assuming Column R has no formulas, then this single line of code will do the copy you seek...
Code:
[table="width: 500"]
[tr]
	[td]Sub Sort_Deployed()
  Sheets("Master").Columns("A").SpecialCells(xlConstants).Copy Sheets("Deployed").Cells(Rows.Count, "A").End(xlUp).Offset(1)
End Sub[/td]
[/tr]
[/table]
If, on the other hand, if you really meant you only wanted to copy text (non-numeric) values, then give this version a try instead...
Code:
[table="width: 500"]
[tr]
	[td]Sub Sort_Deployed()
  Sheets("Master").Columns("A").SpecialCells(xlConstants, xlTextValues).Copy Sheets("Deployed").Cells(Rows.Count, "A").End(xlUp).Offset(1)
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
I did try that one. It only copied one column. I need it to copy all items in a row if column R has text in it.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top