evanpek87
03-27-2015, 11:08 AM
Hi I'm trying to verify that all the records in one column are in the second column. Simple program. However, it never makes it past the point where the second column has a value that isn't in the first column. The point of this code is that the program skips to the next value when it can't find the current one anywhere in the first column. Here is the code, and thanks for any help.
Private Sub RunMatch_Click()
Dim maxRange, minRange As Integer
Dim aVal, bVal As String
minRange = CInt(minValue.Text)
maxRange = CInt(noRecords.Text)
For i = minRange To maxRange
aVal = Cells(i, "A")
bVal = Cells(i, "B")
If aVal = bVal Then
Cells(i, "C").Value = "1"
Else
For j = i + 1 To maxRange
aVal = Cells(j, "A")
If aVal = bVal Then
Cells(i, "C").Value = "1"
Exit For
Else
End If
Next j
End If
Next i
End Sub
Private Sub RunMatch_Click()
Dim maxRange, minRange As Integer
Dim aVal, bVal As String
minRange = CInt(minValue.Text)
maxRange = CInt(noRecords.Text)
For i = minRange To maxRange
aVal = Cells(i, "A")
bVal = Cells(i, "B")
If aVal = bVal Then
Cells(i, "C").Value = "1"
Else
For j = i + 1 To maxRange
aVal = Cells(j, "A")
If aVal = bVal Then
Cells(i, "C").Value = "1"
Exit For
Else
End If
Next j
End If
Next i
End Sub