Sub FIND_PAIRS()
'Application.ScreenUpdating = False
Dim x As Long, y As Long, c As Long, r As Long, k As Long
Dim Lword As String, Rword As String
x = 1
Do Until IsEmpty(Sheets("mysheet1").Cells(x, 1))Sheets("mysheet1").Activate
Lword = Cells(x, 1).Value
Rword = Cells(x, 2).Value
Sheets("mysheet2").Activate
c = 1
k = 1
Do Until IsEmpty(Cells(k, c)) And Cells(k, c).Row = 1
If c = 1 Then
If Cells(k, c).Value = Lword And Cells(k, c + 1).Value = Rword Then
'YOUR CODE HERE
MsgBox Lword & " and " & Rword & " are on " & k & " row," & vbNewLine & _
" columns are: 1 and " & c + 1
'YOUR CODE HERE
k = k + 1
ElseIf IsEmpty(Cells(k, c)) Then
c = c + 1
k = 1
Else
k = k + 1
End If
ElseIf c > 1 Then
If Cells(k, c).Value = Lword And Cells(k, c + 1).Value = Rword Or _
Cells(k, c).Value = Lword And Cells(k, c - 1).Value = Rword Then
'YOUR CODE HERE
MsgBox Lword & " and " & Rword & " are on " & k & " row," & vbNewLine & _
"one of them is in column: " & c
'YOUR CODE HERE
k = k + 1
ElseIf IsEmpty(Cells(k, c)) Then
c = c + 1
k = 1
Else
k = k + 1
End If
End If
Loop
x = x + 1
Loop
Application.ScreenUpdating = True
End Sub
Bookmarks