compare list a & b and add records of b not in a to a

ImplodedBrain

New Member
Joined
May 27, 2002
Messages
6
HI,
I suspect this is yet another VLOOKUP type question, but after much fandangling I can't make it work.

The only complicating factor is that the lists are on different worksheets
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
This routine has your master list on Sheet1, Column A and the list to run through on Sheet2, Column A

It will run through each cell on Sheet2 and compare it to the list on Sheet1. Only those missing from the Sheet 1 list will be added. It resets the master list after each pass so that any duplicate missing items are added only once.

Code:
Sub test()
Dim Rng1 As Range, Rng2 As Range, C As Range
Dim Z

With Sheets("Sheet2")
    .UsedRange
    Set Rng2 = Intersect(.UsedRange, .Range("A:A"))
    For Each C In Rng2
        With Sheets("Sheet1")
        .UsedRange
            Set Rng1 = Intersect(.UsedRange, .Range("A:A"))
            Z = Application.Match(C, Rng1, 0)
            If WorksheetFunction.IsError(Z) Then
                .Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = C
            End If
        End With
    Next C
End With
MsgBox "Done!"

End Sub

HTH,
Jay
 
Upvote 0
Another option, probably more time-consuming though in the long run, is advanced filter :

copy list B so it sits directly underneath list A

highlight the range
data
filter
advanced filter
action = copy to another location
list range = should already be highlighted
copy to = the cell you want to put them
unique value = checked
hit "ok"

Admittedly, this gives you a list of unique values........ so if you original A list or you B list themselves contained duplicates which you wanted retaining, this won't work
 
Upvote 0

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top