Im looking to compare all entries in column B of WB1 (can vary in amount up to 300,000), versus a master listing in WB2,tab "Guide", column A (circa 500 entries).
If there are new entries in column B of WB1, i have a msgbox appear listing the new types to be added to the master listing in WB2.
I would also like a msgbox to appear saying "all types valid" if there are no new types found
Any help greatly appreciated.
Sub Compare()
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim lr1 As Long
Dim lr2 As Long
Dim rng1 As Range
Dim rng2 As Range
Dim c As Range
Dim msg As String
msg = "New types: "
Set sh1 = Sheets(1)
Workbooks.Open Filename:="filepath\Types.xls"
Set sh2 = Worksheets("Guide")
lr1 = Application.WorksheetFunction.CountA(sh1.Columns(1))
lr2 = Application.WorksheetFunction.CountA(sh2.Columns(1))
Set rng1 = sh1.Range("B2:B" & lr1)
Set rng2 = sh2.Range("A2:A" & lr2)
For Each c In rng1
If Len(c.Value) > 0 And Application.CountIf(rng2, c.Value) = 0 Then
msg = msg & vbNewLine & c.Value
End If
Next
Workbooks("Types.xls").Close SaveChanges:=False
MsgBox msg
End Sub