VBA for cell with any text in it

JLGUZMAN

New Member
Joined
Jun 15, 2018
Messages
8
Hello all,
Need some help figuring this out. I am trying to create a macro to search a specific column for any text value and it copy it. I have the copy/paste part down, I need a way to have it search the column for any text. Text values vary by school names and they can change.

Thank you


Sub CopyDeployed()

a = Worksheets("Master").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("Master").Cells(i, 18).Value = 'this is where I need help' Then
Worksheets("Master").Rows(i).Copy
Worksheets("Deployed").Activate
b = Worksheets("Deployed").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Deployed").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Master").Activate
End If
Next
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What do you mean by: "any text value"? Can you give us a few examples of what to look for?
 
Upvote 0
One cell may contain "GW High" an other may have "Chavez Middle" and so on. I would like any cell that has any text in it to copy to the other sheet I have already denoted in the code. THank you
 
Upvote 0
Hopefully, I have understood correctly. Try this macro:
Code:
Sub CopyDeployed()
    Application.ScreenUpdating = False
    Dim LastRow As Long, rng As Range
    LastRow = Sheets("Master").Range("A" & Rows.Count).End(xlUp).Row
    For Each rng In Sheets("Master").Range("R2:R" & LastRow)
        If rng <> "" Then
            rng.EntireRow.Copy Sheets("Deployed").Cells(Sheets("Deployed").Rows.Count, "A").End(xlUp).Offset(1, 0)
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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