You can just use the below code.
Code:
Sub CopyMissingEntries()
'change these Const values
'as required
'name of sheet with short list
Const sheet1Name = "Sheet1"
'column short list is in
Const shortListCol = "A"
'first row with list data
Const firstShortRow = 2
'name of sheet with long list
Const sheet2Name = "Sheet2"
'column long list is in
Const longListCol = "A"
'first row with list data
Const firstLongRow = 2
Dim shortSheet As Worksheet
Dim shortList As Range
Dim anySLEntry As Range
Dim longSheet As Worksheet
Dim longList As Range
Dim anyLLEntry As Range
Dim foundFlag As Boolean
Set shortSheet = Worksheets(sheet1Name)
Set shortList = shortSheet.Range(shortListCol & _
firstShortRow & ":" & _
shortSheet.Range(shortListCol & Rows.Count). _
End(xlUp).Address)
Set longSheet = Worksheets(sheet2Name)
Set longList = longSheet.Range(longListCol & _
firstLongRow & ":" & _
longSheet.Range(longListCol & Rows.Count). _
End(xlUp).Address)
'to improve performance
Application.ScreenUpdating = False
'do the real work
For Each anyLLEntry In longList
foundFlag = False
For Each anySLEntry In shortList
If anySLEntry = anyLLEntry Then
foundFlag = True
Exit For ' out of inner loop
End If
Next
If Not foundFlag Then
'add to short list
shortSheet.Range(shortListCol & _
Rows.Count).End(xlUp).Offset(1, 0) = anyLLEntry
'get new short list range
Set shortList = shortSheet.Range(shortListCol & _
firstShortRow & ":" & _
shortSheet.Range(shortListCol & Rows.Count). _
End(xlUp).Address)
End If
Next
'housekeeping
Set shortList = Nothing
Set shortSheet = Nothing
Set longList = Nothing
Set longSheet = Nothing
'announce completion
MsgBox "Task Completed"
End Sub
Bookmarks