Hi everyone,
Pls help me fix this code below. I want to highlight cells with conditions as follow list
- If col(I)=P then color col Q,R,S,T into green
- If col(I)=P and col(Y) start with “Rev*” or “REV*” then color col Q,R,S,T into yellow
- If remove value in col(Y) then col Q,R,S,T into green back
- If remove value in col(I) then col Q,R,S,T nofill
Thanks for you help.
Code
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 9 And Target.Column <> 25 Then Exit Sub 'only run if input date in col I and col Y
If Target.Row <= 5 Then Exit Sub "only run from row 5
If Not IsEmpty(Cells(Target.Row, 4)) Then Exit Sub 'only run if col D blank
If Target.Column = 9 And Target.Value = "P" Then
Target.Offset(0, 8).Interior.ColorIndex = 4
Target.Offset(0, 9).Interior.ColorIndex = 4
Target.Offset(0, 10).Interior.ColorIndex = 4
Target.Offset(0, 11).Interior.ColorIndex = 4
ElseIf Cells(Target.Row, 9) = "P" Or Left(Target.Row, 25),3) = "Rev" Then 'check if no
Target.Offset(0, -8).Interior.ColorIndex = 6
Target.Offset(0, -7).Interior.ColorIndex = 6
Target.Offset(0, -6).Interior.ColorIndex = 6
Target.Offset(0, -5).Interior.ColorIndex = 6
Else
Target.Offset(0, 8).Interior.ColorIndex = xlNone
Target.Offset(0, 9).Interior.ColorIndex = xlNone
Target.Offset(0, 10).Interior.ColorIndex = xlNone
Target.Offset(0, 11).Interior.ColorIndex = xlNone
End If
End Sub
Display More