Hi Forum!
I'm trying to copy all the values that are not found into column J. But get an error at the line
Any ideas why?
I'm trying to copy all the values that are not found into column J. But get an error at the line
Code:
Selection.Copy Destination:=Sheets(1).Range(lastrange).Paste
Code:
Option Explicit
Sub codeforP()
Dim lastrange As Long
Dim lastrow1 As Long
Dim lastrow2 As Long
Dim business As Variant
Dim i As Long
Dim a As Long
lastrange = Sheets(1).Range("J" & Rows.Count).End(xlUp).Row
lastrow1 = Sheets(1).Range("I50000").End(xlUp).Row
lastrow2 = Sheets(1).Range("F57000").End(xlUp).Row
For i = 2 To lastrow1
business = Sheets(1).Cells(i, "I").Value
For a = 1 To lastrow2
If Sheets(1).Cells(a, "F").Value = business Then
Else
Sheets(1).Cells(a, "F").Select
Selection.Copy Destination:=Sheets(1).Range(lastrange).Paste
End If
Next a
Next i
MsgBox "ok"
End Sub