So basically I have a bunch of data in wksht1 that I want to scan through to select all the rows that adhere to a certain if then statement (see code below) and then copies them to pastesht. I have my code so far but it gives me an error at line 20 and I can't figure out what I need to fix. Please help and thanks in advance!
1 Sub Try()
2 Dim wksht1 As Worksheet, pastesht As Worksheet
3 Dim LastRowinpastesht As Long
4
5 With ThisWorkbook
6 Set wksht1 = Sheets("AAA")
7 Set pastesht = Sheets("PPP")
8 LastRowinpastesht = pastesht.Cells(Rows.Count, 1).End(xlUp).Row + 1
9 End With
10
11 With wksht1
12 Last1 = Cells(Rows.Count, "B").End(xlUp).Row
13 For p = Last1 To 1 Step -1
14 If (Cells(p, "F").Text) = "SSSS" And (Cells(p, "U").Value) <= 5 And (Cells(p, "U").Interior.ColorIndex) = xlNone Then
15 Cells(p, "A").EntireRow.Select
16 Selection.Copy
17 End If
18
19 With pastesht
20 Cells(LastRowinpastesht, 1).Paste
21 Application.CutCopyMode = False
22 End With
23 Next p
24 End With
25 End Sub