Conditional Formatting options

  • Thread starter Thread starter smith.james0
  • Start date Start date
S

smith.james0

Is there any way of getting more than three conditions when conditiona
formatting
 
I want the cells to change colour depandent on the value in them, i nee
4 colours tho :rolleyes
 
If one of the colors is the default color, you can use CF. Otherwise use
the reference I gave you.

smith.james0
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top