... I would like to apply more than 3 conditional formats ...

D

Dr. Darrell

I would like my Cells to be shaded based on the Values that are entered into
them.

I thought that Conditional Formating would be the answer, but it appears I'm
only able to enter three conditions.

I have a posibility of five values that could be entered into the cells:
"-", "1", "2", "3" or "4".

The conditions I reqiure are"

if the cell contains "-", then shade "light yellow"
if the cell contains "1", then no shade
if the cell contains "2", then shade "grey"
if the cell contains "3", then shade "yellow"
if the cell contains "4", then shade "red"

Is there a means to enter more than the three conditions that are allowed by
the dialog box?

Respectfully,
Darrell
 
B

Bob Phillips

Here is an example


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 1: .Interior.ColorIndex = 3 'red
Case 2: .Interior.ColorIndex = 6 'yellow
Case 3: .Interior.ColorIndex = 5 'blue
Case 4: .Interior.ColorIndex = 10 'green
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

Dr. Darrell

Bob:

Thanks for the response. Do you mind if I ask you to disect the code and
explain the meaning of each statement?

Respectfully,
Darrell
 

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

Top