Substitute c. for something else
Also, this line:
.Color = RGB(222, 222, 222)
To this:
.Interior.Color = RGB(222, 222, 222)
And I omitted the x = x + 1 when I re-wrote the
If statement, so it needs to be added back in.
"JLGWhiz" wrote in message
...
If x = 2 Then
rng = rgc.Address
End If
x = x + 1
If x = 2 Then
Range(rgc, rng.Offset(0, 1)).Select
With Selection.Interior
There is a logic problem here. If x is not equal to 2 in the first
occurrence then the variable rng does not get initialized, so the second
If ... Then statement will fail, becaues rng will be empty. You could
write it this way.
If x = 2 Then
rng = rgc.Address
With Range(rng, rng.Offset(0, 1))
.Color = RGB(222, 222, 222)
.Pattern = xlSolid
End With
End If
x = 1...etc.
"smandula" wrote in message
...
Hello again,
I tried the above solution, No Luck
Here's another twist, came up with, still doesn't work
Somewhat, more simple
Sub sequence()
Dim rgc As Range
x = 1
For Each rgc In Range("B2:AX34")
If rgc.Offset(, 1).Value - rgc.Value = 1 Then
If x = 2 Then
rng = rgc.Address
End If
x = x + 1
If x = 2 Then
Range(rgc, rng.Offset(0, 1)).Select
With Selection.Interior
.Color = RGB(222, 222, 222)
.Pattern = xlSolid
End With
x = 1
End If
Else
x = 1
End If
Next
End Sub
Thank's for your reply
|