Hi Guys
I have the following code here..part of it.
If Range("B2").Value = Range("C2").Value Then
How can I loop it so that it goes to the next range value? like B3 = C3 etc?
Thanks for the help.
Printable View
Hi Guys
I have the following code here..part of it.
If Range("B2").Value = Range("C2").Value Then
How can I loop it so that it goes to the next range value? like B3 = C3 etc?
Thanks for the help.
[vba] dim i as long
for i = 2 to 3 Then' or final row you want to loop for
If Cells(i,2).Value = Cells(i,3).Value
'some stuff
End If
Next i[/vba]
Do you mean this?Quote:
Originally Posted by CatDaddy
Thanks.
Im not sure why but im getting a type mismatch error 13 for this..Some columns are vlookup. Does this affect it?
[vba]
Sub Match()
Dim i As Integer
Dim FirstMatch As Boolean
Dim SecondMatch As Boolean
For i = 2 To 3
If Cells(i, 2).Value = Cells(i, 3).Value Then 'Cells (row,column)'B = C ' Also need to find last Record
FirstMatch = True
Else
FirstMatch = False
End If
If Cells(i, 4).Value = Cells(i, 5).Value Then 'Cells (row,column)'D = E ' Also need to find last Record
SecondMatch = True
Else
SecondMatch = False
End If
If FirstMatch = True And SecondMatch = True Then
Cells(i, 1).Value = "x" 'Print in Column A String
else
Cells(i, 1).Value = "False" 'Print in Column A String
End If
Next i
End Sub
[/vba]