Adding more than three Conditions to 'Conditional Formatting'

R

Rizitsu

Can i add more than three conditions to the conditional formatting
presets using code?

Regards

[Riz]
 
P

Paul B

Riz, as you have found out, only 3 conditions with conditional formatting.
But yes you can use some code to get more than 3, try this it will change
the cell color in column A when you put in one ,two, three, or four, right
click on the sheet tab and view code, paste it in the window that opens.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
With Target
Select Case LCase(.Value)
Case Is = "one": .Interior.ColorIndex = 5
Case Is = "two": .Interior.ColorIndex = 6
Case Is = "three": .Interior.ColorIndex = 7
Case Is = "four": .Interior.ColorIndex = 8
Case Else
.Interior.ColorIndex = xlNone
End Select
End With
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
M

mark_b2410

This isn't help but...

Can you hide rows/cells using conditional formatting?

If so, how?

Thanks

mar
 
G

Gord Dibben

mark

You cannot hide rows using CF.

You could color the font to white so's it doesn't show up on-screen.

Then you have to make the cells "hidden" so's they wouldn't show in the
Formula Bar.

Then you have to protect the worksheet so's users could not change things.

You would be better off using VBA code to hide the rows based on some
condition.

Gord Dibben Excel MVP
 
G

Gord Dibben

Select the cell(s)

Format>Cells>Protection. Check "Hidden" and OK your way out.

When worksheet protection is enabled, you will see nothing in the Formula Bar.

Gord
 
D

David McRitchie

Hi Mark,
Not with Conditional Formatting, but you can use Auto Filter
and the formulas just like Conditional Formatting are
Worksheet Functions that return either True or False.

See Debra Dalgleish's site contextures.com
Excel Filters -- Advanced Filter -- Complex Criteria
http://www.contextures.com/xladvfilter02.html
 
Top