montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 986
- Office Version
- 2010
- Platform
- Windows
Code:
Sub D_W()
Dim X As Range, Y As Range
For Each X In Range("B3:g3")
Set Y = Range("J5:Q10").Find(X, LookIn:=xlValues, lookat:=xlWhole)
If Not Y Is Nothing Then
Y.Interior.ColorIndex = 6
End If
Next X
End Sub
Well, I am trying to replace this ►”FOR/EACH”◄ method, because I don’t see the possible way to control the ranges B:G and J:Q.
What I mean by this?
If I have for next statement I will be able to create two variables like [ X, Y] and just make:
x = Range(“A1”).value, and y = Range(“B1”).value,
so then my loop will be :
For m = x to y etc.
This is the kind of control I need in both ranges of the actual loop, but I don’t see how to do it with for/each statement.
“Any help is always appreciated”.
Thank you for reading this post.