I would like to change the cell background in a excel spreadsheet based on values within the individual cells. The best way I believe to do this is to use VBA since I have more than three conditions. I do not want to have to type the values into the cells again for the code to work which is what i currently have working I would like to have the worksheet automatically update. Like a macro running. Does anyone have any ideas.
Code:
Sub PrettyColors(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A2:E1334")) Is Nothing Then
With Target
Select Case .Value
Case 0 To 10
icolor = 6
Case 11 To 20
icolor = 7
Case 21 To 30
icolor = 8
Case 31 To 40
icolor = 9
Case 41 To 50
icolor = 10
Case 51 To 60
icolor = 11
Case 61 To 70
icolor = 12
Case 71 To 80
icolor = 13
Case 81 To 90
icolor = 14
Case 91 To 100
icolor = 15
Case Else
'Whatever
End Select
End With
Target.Interior.ColorIndex = icolor
End If
End Sub