I have an attached spreadsheet that I inherited with existing values. I am trying to enhance it by adding data validation lists that work in concert with conditional formatting. I found some code that gets around the 3 criteria limit for conditional formatting, but can’t bring it home.
1 – I would like to code to auto fill the existing values based on the established criteria in the code.
2 – I would like the coded criteria to work with the data validation lists that users will enter data on (Columns D, F and I).
3 – I would like Columns E and J to auto calculate based on the formula I created and format to a color specified in the code. How should the default value of “#VALUE!” be recognized so that it autofills to a specified color?
I have written the following code on the Rating worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range(“B2:I9”)) Is Nothing Then
Select Case Target
Case 1 To 1
icolor = 35
Case 2 To 2
icolor = 6
Case 3 To 3
icolor = 44
Case 4 To 4
icolor = 3
Case “N/A”
icolor = 15
Case “?VALUE”
icolor = 75
Case “#VALUE!”
icolor = 12
Case “0”
icolor = 15
Case “LOW”
icolor = 35
Case “MEDIUM”
icolor = 6
Case “High”
icolor = 3
End Select
With Worksheets(“Rating”)
Target.Interior.ColorIndex = icolor
End With
End If
Dim myRange As Range
Set myRange = Worksheets(“Rating”).Range(“B2:I9”)
ActiveWorkbook.RefreshAll
End Sub
1 and LOW are meant to be the same color. So are 2 and MEDIUM and 4 and HIGH.
0 and N/A should be the same colors as well. 0 is a value that is auto-calculated based on the formula in Columns E and J.
Thanks for you help.