montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 986
- Office Version
- 2010
- Platform
- Windows
Hi.
I Hope to be lucky and get some help
I upload this just to illustrate the logic I am trying
I want to read my array B2:F64 and match the M2:AZ37
I think the 3 codes make more sence
read B2:F2 and check if on Column M there are matches and highlight them
read B3:F3 and check if on column N there are matches and hightlight them
etc.
so I tried this
but is working completely wrong
some help would be nice
I Hope to be lucky and get some help
VBA Code:
Sub D_M()
Dim X As Range, Y As Range
For Each X In Range("B2:F2")
Set Y = Range("M2:M37").Find(X, LookIn:=xlValues, lookat:=xlWhole)
If Not Y Is Nothing Then
Y.Interior.ColorIndex = 6
End If
Next X
End Sub
Sub D_N()
Dim X As Range, Y As Range
For Each X In Range("B3:F3")
Set Y = Range("N2:N37").Find(X, LookIn:=xlValues, lookat:=xlWhole)
If Not Y Is Nothing Then
Y.Interior.ColorIndex = 6
End If
Next X
End Sub
Sub D_o()
Dim X As Range, Y As Range
For Each X In Range("B4:F4")
Set Y = Range("O2:O37").Find(X, LookIn:=xlValues, lookat:=xlWhole)
If Not Y Is Nothing Then
Y.Interior.ColorIndex = 6
End If
Next X
End Sub
I want to read my array B2:F64 and match the M2:AZ37
I think the 3 codes make more sence
read B2:F2 and check if on Column M there are matches and highlight them
read B3:F3 and check if on column N there are matches and hightlight them
etc.
so I tried this
VBA Code:
Sub MatchAndHighlight()
Dim i As Long, j As Long
Dim X As Range, Y As Range
Dim col As String
For i = 2 To 34
For j = 13 To 25
For Each X In Range("B" & i & ":F" & i)
Set Y = Range(col & "m:" & col & "bb").Find(X, LookIn:=xlValues, lookat:=xlWhole)
If Not Y Is Nothing Then
Y.Interior.ColorIndex = 6
End If
Next X
Next j
Next i
End Sub
some help would be nice