Jak
Well-known Member
- Joined
- Apr 5, 2002
- Messages
- 833
I a trying to create a macro that checks to see if there is a value in column 1 but not in columns 7, 9, 11, 13, 15, 17, 19, 21, 23, 25. If column 1 does have a value and there are no values in either 7, 9, 11, 13, 15, 17, 19, 21, 23, 25 then the cells are coloured, other wise the cells remain uncoloured.
e.g.
Cell A2 has a value and cells G2, I2, K2, M2, O2, Q2, S2, U2, W2, Y2 are blank then the cells are highlighted.
If Cell A2 has a value and lets say K2 had a value then the cells would remain uncoloured.
I have tried to put a macro together to do this but unfortunately it does not work. Any suggestions on the code or alternative code to do this would be great.
e.g.
Cell A2 has a value and cells G2, I2, K2, M2, O2, Q2, S2, U2, W2, Y2 are blank then the cells are highlighted.
If Cell A2 has a value and lets say K2 had a value then the cells would remain uncoloured.
I have tried to put a macro together to do this but unfortunately it does not work. Any suggestions on the code or alternative code to do this would be great.
Code:
Sub ColorRowsWithMissingData()
Dim rng1 As Range
Dim rng2 As Range
Dim R As Integer
For R = 2 To 1000
Set rng1 = ActiveSheet.Range("A" & R)
Set rng2 = ActiveSheet.Range("G" & R & ", I" & R & ", K" & R & ", M" & R & ", O" & _
R & ", Q" & R & ", S" & R & ", U" & R & ", W" & _
R & ", Y" & R)
If Application.Count(rng1.Cells) = 1 And Application.Count(rng2.Cells) = 0 Then rng2.Cells.Interior.ColorIndex = 36
Next R
MsgBox "job done"
End Sub