Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Script that finds difference. Can i have a way to get each colum Difference in colum H,I or J,K.

Hi,

Script that finds difference. Can i have a way to get each colum Difference in colum H,I or J,K.

its a related post.

Regards
sharath
Avatar of nutsch
nutsch
Flag of United States of America image

Here I've updated my function, you can call it using
in cell J2
=diffmail($D2,$E2,1)
and in cell K2
=diffmail($D2,$E2,2)

Thomas

Function diffMail(str1 As String, str2 As String, lgType As Long)

Dim arr1, arr2
Dim i As Long, j As Long

arr1 = Split(str1, ",")
arr2 = Split(str2, ",")

If lgType = 1 Then
    If str1 = "" Then
        diffMail = str2
        Exit Function
    End If
    
    For i = 0 To UBound(arr2)
    For j = 0 To UBound(arr1)
        If arr1(j) = arr2(i) Then GoTo nxti2
    Next j
    diffMail = diffMail & "," & arr2(i)
nxti2:
Next i
    
Else
    
    If str2 = "" Then
        diffMail = str1
        Exit Function
    End If
    
    For i = 0 To UBound(arr1)
        For j = 0 To UBound(arr2)
            If arr2(j) = arr1(i) Then GoTo nxti
        Next j
        diffMail = diffMail & "," & arr1(i)
nxti:
    Next i

End If

If Len(diffMail) <= 1 Then diffMail = "" Else diffMail = Right(diffMail, Len(diffMail) - 1)

End Function

Open in new window

Avatar of bsharath

ASKER

Its perfect
Can i get the 2 colums to display emails as this

Sha@plc.com,
Shar@plc.com,
Shara@plc.com

One in each row within the cell. So its easy to view.
At present its like this
Sha@plc.com,Shar@plc.com,Shara@plc.com
ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you works perfect