View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
zwestbrook zwestbrook is offline
external usenet poster
 
Posts: 9
Default Compare List A to List B, Return List B Items Not in List A

I've searched on the forum and found ways to list duplicate items and
unique items, but this is for a combination of two lists, not
"bumping" one list against another. In this case, I need to compare
List A to List B and return those items in List B that are not in List
A. I scavenged and tweaked some code, but it is trying to do a cell-to-
cell comparison - this won't work as items can be in different
locations within the lists. Thoughts?

Sub ListDuplicateVal()

Dim Rng1 As Range
Dim Rng2 As Range
Dim Rng3 As Range
Dim Cell As Range

Set Rng1 = Range("A1:A13") 'long list
Set Rng2 = Range("B1:B13") 'short list
Set Rng3 = Range("D1") 'output
On Error Resume Next

For Each Cell In Rng2

If Rng2.Cell.Value < Rng1.Cell.Value Then
Rng3.Value = Cell.Value
Set Rng3 = Rng3.Offset(1, 0)
End If

Next Cell
End Sub