Very new to VBA but really need help on this code.
So, I'd like to copy any cells in Column L in Worksheet1, IF the name is in my named range (in Lookuptab sheet).
So far I have the code for the copy and paste and it works fine but since putting in the countif
criteria, I get the error compile error sub function not defined
Please help!
Thanks,
My code is as follows:
a = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If CountIf(Sheets("Lookup").Range("Vendor_Lookup"), Sheets("Sheet1").Cells(i, 12).Value) > 0 Then
Worksheets("Sheet1").Rows(i).Copy
Worksheets("Sheet2").Activate
b = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet2").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Sheet1").Activate
End If
Next
Application.CutCopyMode = False
End Sub