Right click on the tab you wish to create the color coding on. Paste the following:
<pre>
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim test As Integer, results As Integer
test = Cells(ActiveCell.Row, 1).Value ‘Finds the row number of the cell you edited
Select Case test ‘changes the color of column B, of the row you are editing.
Case Is <= 0
Cells(ActiveCell.Row, 2).Interior.ColorIndex = 3 ‘Red
End
Case 1 To 10
Cells(ActiveCell.Row, 2).Interior.ColorIndex = 6 ‘Yellow
End
Case Is > 10
Cells(ActiveCell.Row, 2).Interior.ColorIndex = 43 ‘Green
End
End Select
End Sub
</pre>
You’ll need to modify that to fit your spreadsheet some, but that is the basics. You need to hit the arrow key instead of the carriage return for this to change the correct cell color.
Discuss This Question: 3  Replies