View Single Post
 
Old 11-01-2018, 03:37 PM
Dave T Dave T is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default Comparing two lists and extracting values missing from both lists

Hello All,

I had originally posted this question on another forum (I have since deleted the post as I suspect it was not the appropriate forum).

I have been using the two macros I found on the stackoverflow site (source link within attached code).

Using an InputBox to select the two columns to compare is exactly what I am after and works very well. Currently the results are hard coded to return the results to cell F5, but I would like to be able to use another InputBox to select the output cell.

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
  
  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("F5").Resize(j) = Application.Transpose(v3)
  
InputCancel:
  
End Sub
How can the currently hard coded output cell of F5 be converted to an InputBox user selected cell.

Regards, Dave T
Reply With Quote