Use VBA To Compare Two Lists and Show The Values in The First Column That Are Missing From The Second Column
Use VBA To Compare Two Lists and Show The Values in The First Column That Are Missing From The Second Column
from
the second column. This is a simple way to compare two lists in Excel and summarize the
results.
This list comparison macro is similar to the compare two columns for differences macro I
created back in 2015, but this one specializes in reporting the missing data in the columns.It
was submitted by wellsrPRO power user, Giancarlo, so we owe him a big thank you!
Psst... it's Free!
Any value in Column 1 (Col_1) that’s not in Column 2 (Col_2) will be printed out in Column
3 (Col_3). The comments in the USER INPUT block explain this really well.
The fourth and final variable, StartRow, is the row where your two lists begin. This macro
inherently assumes your two lists are on the same sheet and they begin at the same row.
When you run the macro, the summary column reports the values in the first list that aren’t
in the second list. You can see that the strings “two” and “five” are missing from the second
list. Run the macro, and those words will appear in Column C.
The macro actually works by evaluating an Excel worksheet formula. It’s basically the same
as highlighting cells C1:C6 and typing the Excel formula…
Once the formula is evaluated, the macro cleans things up by deleting all the blank
cells.What your left with is a compact list of all the items missing from the second list.
I ran this macro on a number of sample lists and it appears to work nicely. It does get
bogged down a bit when comparing lists containing about 10,000 entries, but that’s to be
expected.
I hope you enjoyed this tutorial. Send a big thanks to Giancarlo in the comments section if
you found it helpful.