Try this..
Private Sub CommandButton1_Click()
Dim x, j As Long, jj As Long, Msg1, i As Integer, ii As Integer, r As Integer
Msg1 = MsgBox("A--->B = Yes, B--->A = No", vbYesNo, "Select")
If Msg1 = vbYes Then
i = 1: ii = 2: r = 2
Else
i = 2: ii = 1: r = 5
End If
With Range("A1").CurrentRegion
x = .Offset(1).Resize(.Rows.Count - 1)
End With
With CreateObject("scripting.dictionary")
For j = 1 To UBound(x)
x0 = .Item(x(j, ii))
Next
For jj = 1 To UBound(x)
If Not .Exists(x(jj, i)) Then
If Cells(r, 3).Value = "" Then
Cells(r, 3).Value = x(jj, i)
ElseIf Not IsEmpty(x(jj, i)) = True Then Cells(r, 3).Value = Cells(r, 3).Value & ";" & x(jj, i)
End If
End If
Next jj
End With
End Sub
Bookmarks