Hello Gurus,
Can you please help me with the code?
Problem:
I would like to shade cells in r2 (A1:B10) with grey color based on value of cells in r1 (C1:D10, empty or non-empty).
eg: If C1 is empty, A1 should be shaded grey
If D5 is empty, B5 should be shaded grey
The code below works but it only takes value from column C and disregards values in column D.
Can you please help?
Thanks
Can you please help me with the code?
Problem:
I would like to shade cells in r2 (A1:B10) with grey color based on value of cells in r1 (C1:D10, empty or non-empty).
eg: If C1 is empty, A1 should be shaded grey
If D5 is empty, B5 should be shaded grey
The code below works but it only takes value from column C and disregards values in column D.
Can you please help?
Thanks
Code:
Sub loopColor()
Dim i As Long, r1 As Range, r2 As Range
For i = 1 To 10
Set r1 = Range("C" & i)
Set r2 = Range("A" & i & ":B" & i)
If r1.Value = "" Then r2.Interior.coloridex = 16
Next i
End Sub