Hello,
I have two lists of data, and I need to find the matches between them. I wrote a sub in VBA to do this, but it never runs completely. After inserting a counter, I notice that it always freezes after 236000. I can't seem to find any error with the code, and I'm hoping someone can help me. The code is as follows:
Sub Matching()
Dim i As Long: i = 2
Dim j As Long
Dim k As Long: k = 1
Dim m As Long: m = 1
Dim a As String
Dim b As String
Do
a = Sheet2.Cells(i, 1).Value
j = 2
If i = 10 * k Then
k = k + 1
Sheet1.Cells(1, 80).Value = i
End If
Do
b = Sheet1.Cells(j, 1).Value
If a = b Then
Cells(i, 80).Value = "Match Found"
End If
If j = 10 * m Then
m = m + 1
Sheet1.Cells(1, 81).Value = j
End If
j = j + 1
Loop Until Sheet1.Cells(j + 1, 1).Value = "END"
i = i + 1
Loop Until Sheet2.Cells(i + 1, 1).Value = "END"
End Sub
Also, only the counter in cell(1,81) is activated, it never reaches the counter in cell(1,80).
Can you please help me with this?
I have two lists of data, and I need to find the matches between them. I wrote a sub in VBA to do this, but it never runs completely. After inserting a counter, I notice that it always freezes after 236000. I can't seem to find any error with the code, and I'm hoping someone can help me. The code is as follows:
Sub Matching()
Dim i As Long: i = 2
Dim j As Long
Dim k As Long: k = 1
Dim m As Long: m = 1
Dim a As String
Dim b As String
Do
a = Sheet2.Cells(i, 1).Value
j = 2
If i = 10 * k Then
k = k + 1
Sheet1.Cells(1, 80).Value = i
End If
Do
b = Sheet1.Cells(j, 1).Value
If a = b Then
Cells(i, 80).Value = "Match Found"
End If
If j = 10 * m Then
m = m + 1
Sheet1.Cells(1, 81).Value = j
End If
j = j + 1
Loop Until Sheet1.Cells(j + 1, 1).Value = "END"
i = i + 1
Loop Until Sheet2.Cells(i + 1, 1).Value = "END"
End Sub
Also, only the counter in cell(1,81) is activated, it never reaches the counter in cell(1,80).
Can you please help me with this?