Last active
October 13, 2015 22:08
-
-
Save mrowles/4263018 to your computer and use it in GitHub Desktop.
Microsoft Excel: Changes the colour of a row based on a particular value in a cell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Note: needs to be attached to a worksheet | |
Private Sub Worksheet_Change(ByVal Target As Range) | |
'Specifies the target column to pay attention to on worksheet change | |
If (Target.Column = 2) Then | |
'Conditional statement based on cell value | |
Select Case Target.Value | |
Case "red" | |
Worksheets("Sheet1").Rows(Target.Row).Interior.ColorIndex = 3 | |
Case "blue" | |
Worksheets("Sheet1").Rows(Target.Row).Interior.ColorIndex = 5 | |
Case "green" | |
Worksheets("Sheet1").Rows(Target.Row).Interior.ColorIndex = 4 | |
Case Else | |
Worksheets("Sheet1").Rows(Target.Row).Interior.ColorIndex = xlNone | |
End Select | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment