I am in need of a VBA script to change an adjacent cell one of three colors. The first part of my script works fine. And this becomes my reference cell. I need the cell to the right of reference cell changed to the proper color. This is because my reference cells which are in multiple columns get erased prior to publication. I have commented out my attempts to change the color of adjacent cells. So far I seem to get the adjacent cell changed to green regardless of what color I try.
Any help would be appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
Set Crayon = Range("A1:BY21")
For Each Cell In Crayon
'Change formula cell color to match output value
If Cell.Value = "Green" Then
Cell.Interior.ColorIndex = 4
End If
If Cell.Value = "Yellow" Then
Cell.Interior.ColorIndex = 6
End If
If Cell.Value = "Red" Then
Cell.Interior.ColorIndex = 3
End If
'Change adjacent cell color to match ouput value
'If Cell.Value = "Green" Then
'ActiveCell.Offset(0, 1).Interior.ColorIndex = 4
'End If
'Change adjacent cell color to match ouput value 2nd option
'If Cell.Value = "Green" Then
'Target.Offset(Crayon.Row - 1, Crayon.Column).Interior.ColorIndex = 4
'End If
'If Cell.Value = "Yellow" Then
'Target.Offset(Crayon.Row - 1, Crayon.Column).Interior.ColorIndex = 6
'End If
'If Cell.Value = "Red" Then
'Target.Offset(Crayon.Row - 1, Crayon.Column).Interior.ColorIndex = 3
'End If
Next
End Sub
Regards,
Jerry Keller
Any help would be appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
Set Crayon = Range("A1:BY21")
For Each Cell In Crayon
'Change formula cell color to match output value
If Cell.Value = "Green" Then
Cell.Interior.ColorIndex = 4
End If
If Cell.Value = "Yellow" Then
Cell.Interior.ColorIndex = 6
End If
If Cell.Value = "Red" Then
Cell.Interior.ColorIndex = 3
End If
'Change adjacent cell color to match ouput value
'If Cell.Value = "Green" Then
'ActiveCell.Offset(0, 1).Interior.ColorIndex = 4
'End If
'Change adjacent cell color to match ouput value 2nd option
'If Cell.Value = "Green" Then
'Target.Offset(Crayon.Row - 1, Crayon.Column).Interior.ColorIndex = 4
'End If
'If Cell.Value = "Yellow" Then
'Target.Offset(Crayon.Row - 1, Crayon.Column).Interior.ColorIndex = 6
'End If
'If Cell.Value = "Red" Then
'Target.Offset(Crayon.Row - 1, Crayon.Column).Interior.ColorIndex = 3
'End If
Next
End Sub
Regards,
Jerry Keller