Hi

I am using the bellow code to compare two arrays but it is not comparing them the way I want

Sub CompareArrays()
Dim ar1() As String
Dim ar2() As String
Dim i As Integer

ar1 = Split("Muhammad Imran Bhatti", " ")
ar2 = Split("Bhatti Imran Muhammad", " ")

For i = LBound(ar1) To UBound(ar1)
    If ar1(i) = ar2(i) Then
    MsgBox ar1(i) & "---" & ar2(i)
    End If
Next i

End Sub
What I want this code to do is
show msgbox like
Muhammad---Bhatti
Muhammad---Imran
Muhammad---Muhammad

Then
Imran---Bhatti
Imran---Imran
Imran---Muhammad

Then
Bhatti---Bhatti
Bhatti---Imran
Bhatti---Muhammad

Hope it makes sense

Best Regards
Imran Bhatti