UDF
Use in cell like
For Excel version with spill functionality.
=AddDel(A2,B2)
the copy down
For non spill version
=AddDel($A2,$B2,COLUMN(A1))
copy to the right + down
Function AddDel(txt1 As String, txt2 As String, Optional ref As Long)
Dim w, x, y, i As Long, ii As Long
x = Split(txt1, ","): y = Split(txt2, ",")
For i = 0 To UBound(x)
For ii = 0 To UBound(y)
If (y(ii) <> Chr(2)) * (x(i) = y(ii)) Then
x(i) = Chr(2): y(ii) = Chr(2): Exit For
End If
Next
Next
x = Filter(x, Chr(2), 0): y = Filter(y, Chr(2), 0)
If UBound(x) > -1 Then
x = Join(x, ",")
Else
x = vbNullString
End If
If UBound(y) > -1 Then
y = Join(y, ",")
Else
y = vbNullString
End If
w = Array(y, x)
If ref Then
AddDel = w(ref - 1)
Else
AddDel = w
End If
End Function
Bookmarks