View Single Post
 
Old 11-01-2018, 03:59 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi Dave,

Maybe...

Code:
Sub ExtractUniqueItems()
  'https://stackoverflow.com/questions/49115014/comparing-two-lists-in-excel-and-extracting-values-missing-from-2nd-list-canno
  
    Dim v1, v2, v3(), i As Long, j As Long
    Dim iCell As Range
    Dim r     As Range
    On Error Resume Next
    Set r = Application.InputBox("Click on a cell for the output", Type:=8)
    On Error GoTo 0
    If r Is Nothing Then Exit Sub
  
    On Error GoTo InputCancel
    
    v1 = Application.InputBox("First list", "VALUES TO COMPARE", Type:=8)
    v2 = Application.InputBox("Second list", "VALUES TO BE COMPARED WITH", Type:=8)
    
    ReDim v3(1 To UBound(v1, 1))
    
    For i = LBound(v1) To UBound(v1)
      If IsError(Application.Match(v1(i, 1), v2, 0)) Then
        j = j + 1
        v3(j) = v1(i, 1)
      End If
    Next i
    
    Range(r.Address).Resize(j) = Application.Transpose(v3)
    
InputCancel:
  
End Sub
Reply With Quote