printmedia
asked on
Change row color based on cell value in Excel 2007 VBA
Hi all.
I have the code below that changes the color of a cell if it equals "SHEET". But I want to take it to the next level by highlighting the row from Column A to Column E. How can I do this?
Thank you in advance!
I have the code below that changes the color of a cell if it equals "SHEET". But I want to take it to the next level by highlighting the row from Column A to Column E. How can I do this?
Thank you in advance!
Dim rng2 As Long
With Worksheets("Sheet1")
rng2 = .Range("A" & Rows.Count).End(xlUp).Row
.Range("I3:I" & rng2).NumberFormat = "$ 0.0000"
.Range("D3:D" & rng2).Columns.AutoFit
.Range("J3:J" & rng2).Columns.AutoFit
.Range("K3:K" & rng2).Columns.AutoFit
.Range("L3:L" & rng2).Columns.AutoFit
Set MR = Range("J3:J" & rng2)
For Each cell In MR
If cell.Value = "SHEET" Or cell.Value = "Sheet" Then cell.Interior.ColorIndex = 36
Next
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again Stephen! I'll be posting some more questions.
Open in new window