I am using this code to check each row in worksheet "Report2" for the phrase "Chicago" and copy and paste any rows with "Chicago" in them into a new sheet. However, it is not working. Any help on why would be appreciated.
Sub BranchCount()
Dim s As Worksheet
Dim LastRow As Long
Set s = Worksheets("Report 1")
LastRow = s.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Worksheets("Report 1").Select
Range("A1:J" & LastRow).Select
Selection.Copy
Sheets.Add.Name = "Report2"
Selection.PasteSpecial xlPasteValues
Range("A1").EntireRow.Delete
Range("B1").EntireRow.Delete
Range("C1").EntireRow.Delete
Dim Z As Range
Dim Y As String
Y = "Chicago"
Dim Q As Worksheet
Dim LastRow2 As Long
Set Q = Worksheets("Report2")
LastRow2 = Q.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Sheets("Report2").Range("A1").Select
For Each Z In Range("J1:J" & LastRow2)
If Y = Z.Value Then
Z.EntireRow.Copy
Sheets("Clean").Select
Range("A500").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial xlPasteValues
Sheets("Report2").Select
End If
Next
End Sub
I use Excel 2013. Please let me know if you can help. Thanks!