Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
I used this formula for a project status report that required 4 colors
(added cases for another spreadsheet requiring 8 colors). Right click on the worksheet name -- select View Code -- paste this formula. The result: when "Green" is entered in a cell, both the background and the font is green. You can replace the verbiage in quotation with your specific value. Remove the font section if you just want to change the cell shading. Private Sub Worksheet_Change(ByVal Target As Range) Dim Num As Long Dim rng As Range Dim vRngInput As Variant Set vRngInput = Intersect(Target, Range("a6:af250")) If vRngInput Is Nothing Then Exit Sub For Each rng In vRngInput 'Determine the color Select Case rng.Value Case Is = "Green": Num = 4 'green Case Is = "Yellow": Num = 6 'yellow Case Is = "Red": Num = 3 'red Case Is = "Blue": Num = 11 'dark blue End Select 'Apply the color to background rng.Interior.ColorIndex = Num 'Determine the color Select Case rng.Value Case Is = "Green": Num = 4 'green Case Is = "Yellow": Num = 6 'yellow Case Is = "Red": Num = 3 'red Case Is = "Blue": Num = 11 'dark blue End Select 'Apply the color to the font rng.Font.ColorIndex = Num Next rng End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional Formatting Error | Excel Worksheet Functions | |||
difficulty with conditional formatting | Excel Discussion (Misc queries) | |||
conditional formatting question | Excel Discussion (Misc queries) | |||
Determine cells that drive conditional formatting? | Excel Discussion (Misc queries) | |||
Conditional formatting not available in Excel | Excel Discussion (Misc queries) |