I have the following code that is looking for cells with 39 in them and then cutting and pasting those rows into a different sheet. The full data is in Col A through Col R. I'm looking for cells in Col R with 39.
I have this in my Personal.xls file. The first time I testing this it worked. The AutoFilter Method of Range Class Failed error occurs at the line in red.
Sub RemPurple()
Sheets("Add On & Opex").Select
LastRow = Sheets("Add On & Opex").Cells(Rows.Count, "D").End(xlUp).Row
Range("R5").AutoFilter Field:=18, Criteria1:="39"
Range("A5:R" & LastRow).SpecialCells(xlCellTypeVisible).Cut
Sheets("L3 Closed").Select
lastrow2 = Sheets("L3 Closed").Cells(Rows.Count, "D").End(xlUp).Row + 1
Rows(lastrow2).Select
ActiveSheet.Paste
Sheets("Add On & Opex").Select
Selection.AutoFilter Field:=1
Selection.AutoFilter
End Sub
Please tell me what I'm doing wrong. I'm a novice to VBA.
Any help would be greatly appreciated.
I have this in my Personal.xls file. The first time I testing this it worked. The AutoFilter Method of Range Class Failed error occurs at the line in red.
Sub RemPurple()
Sheets("Add On & Opex").Select
LastRow = Sheets("Add On & Opex").Cells(Rows.Count, "D").End(xlUp).Row
Range("R5").AutoFilter Field:=18, Criteria1:="39"
Range("A5:R" & LastRow).SpecialCells(xlCellTypeVisible).Cut
Sheets("L3 Closed").Select
lastrow2 = Sheets("L3 Closed").Cells(Rows.Count, "D").End(xlUp).Row + 1
Rows(lastrow2).Select
ActiveSheet.Paste
Sheets("Add On & Opex").Select
Selection.AutoFilter Field:=1
Selection.AutoFilter
End Sub
Please tell me what I'm doing wrong. I'm a novice to VBA.
Any help would be greatly appreciated.