Hello, I have this code to fetch the values in column A and not in column C and copy them after the last cell that contains a value from column C. I want to execute the same command on several columns, so that column A is compared to columns C through R, and the non-existent ones are copied in each column separately.
VBA Code:
Sub test()
Dim lr As Long, i As Long
Dim WS As Worksheet: Set WS = Worksheets("data")
Application.ScreenUpdating = False
lr = WS.Columns("A:R").Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
For i = 5 To lr
If WorksheetFunction.CountIf(Range("C5:C" & lr), Range("A" & i)) = 0 Then
Cells(Rows.Count, 3).End(xlUp).Offset(1).Value = Range("a" & i).Value
End If
Next i
Application.ScreenUpdating = True
End Sub