AboutStuart Resnick Expertise I can answer any question relating to MS Excel formulas, or to programming with vba (Visual Basic for Applications) in the Excel environment
Experience As a consultant, I've designed Excel tools since the 90s, working for the Federal Reserve Bank, AT&T, and (currently) Gap Inc.
Expert: Stuart Resnick Date: 7/18/2008 Subject: Cross checking two lists
Question I would like a macro to do the following please:
For every customer in column A on a list of customers on sheet 1 check the customer name against a customer list in column A on sheet 2
If not found in column A on sheet 2, add customer name to the bottom of the list on sheet 2
Continue until the end of the list on sheet 1
Thank you
Answer Example: the lists on Sheet1 and Sheet2 both begin in cell A1. Any value in the Sheet1 list that's not on the Sheet2 list gets added to bottom of Sheet2 list:
Sub copyFromColA()
Dim copyFrom As Range, copyTo As Range
Set copyFrom = Sheets("sheet1").Range("a1")
Set copyTo = Sheets("sheet2").Range("a1")
Do Until copyTo = ""
Set copyTo = copyTo.Offset(1)
Loop
Do Until copyFrom = ""
If IsError(Application.Match(copyFrom, copyTo.EntireColumn, 0)) Then
copyTo = copyFrom
Set copyTo = copyTo.Offset(1)
End If
Set copyFrom = copyFrom.Offset(1)
Loop
End Sub