Microsoft Excel has a limit of 3 criteria in Conditional Formatting. We can get around this with a bit of VBA code…
Private Sub Worksheet_Change(ByVal Target As Range)
Dim intclr As Integer
If Not Intersect(Target, Range(”A1:z100″)) Is Nothing Then
Select Case Target
Case “ted”
intclr = 6
Case 6
intclr = 12
Case 11 To 15
intclr = 7
Case 16 To 20
intclr = 53
Case 21 To 25
intclr = 15
Case 26 To 30
intclr = 42
Case Else
End Select
Target.Interior.ColorIndex = intclr
End If
End Sub
Enter the range you want to include in the conditional formatting in the line “If Not Intersect(Target, Range(”A1:z100″)) Is Nothing Then”. Select the conditions (some example conditions are in the sample code following “Case”.
The colors that correspond to the colorindex integer can be found at
ColorIndex
Joseph Harris
Excel Help
Related posts:
- Conditional Formatting Q: Dear ExcelYogi, Thank you for all your wonderful advise...
- ColorIndex Reference - Excel VBA A chart that can be used to look up the...
- Playing with VBA in Excel, Without Knowing VBA! Introduction to user defined functions and VBA in Excel....
- Sum by the Color of a Cell - Excel Surfing the web today, I came across a great user...
- User Passwords in Excel - Multiple Passwords Simple multiple user password protection in Excel....










i am using your conditonal formating script in vba for excel but i have one issue i hope you can help, it works fine when you change one cell at a time, but for instance when i highlight a row and hit the del key i get an error, if i hit ignore it does what i want but is there a way to get around that
thanks