View Full Version : Solved: Look excel range?
lienlee
07-06-2011, 11:42 AM
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.
CatDaddy
07-06-2011, 11:50 AM
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
lienlee
07-07-2011, 07:03 AM
dim i as long
for i = 2 to 3 ' or final row you want to loop for
If Cells(i,2).Value = Cells(i,3).Value Then
'some stuff
End If
Next i
Do you mean this?
Thanks.
Im not sure why but im getting a type mismatch error 13 for this..Some columns are vlookup. Does this affect it?
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.