ChristineJ
Well-known Member
- Joined
- May 18, 2009
- Messages
- 756
- Office Version
- 365
- Platform
- Windows
The following function does exactly what I need in terms of returning comparing cells A1 and B1 (both have comma delimited text with cell addresses) and returning in C1 those addresses that appear in B1 but not in A1.
Example: A1 D10,D11,E15,E17,E25,F3,G9,G16
B1 G16, E17, M32, H11, D11, D11
C1 M32, H11
Is is possible to convert this function to a macro where the results in C1 only appear when the macro is run? Columns A and B will have content in some (but not all) of the rows between 51 and 239, inclusive.
Thanks so much!
(From: Extracting differences between two comma-separated strings)
Example: A1 D10,D11,E15,E17,E25,F3,G9,G16
B1 G16, E17, M32, H11, D11, D11
C1 M32, H11
Is is possible to convert this function to a macro where the results in C1 only appear when the macro is run? Columns A and B will have content in some (but not all) of the rows between 51 and 239, inclusive.
Thanks so much!
Code:
Function GetUnique(a As String, b As String) As String
Dim i As Long
Dim Sp As Variant, tmp As Variant
Sp = Split(b, ",")
tmp = Split(a, ",")
For i = 0 To UBound(Sp)
tmp = Filter(tmp, Sp(i), False, vbTextCompare)
Next i
GetUnique = Join(tmp, ",")
End Function
(From: Extracting differences between two comma-separated strings)