conditional formatting more than 3 conditions

G

Guest

Guest
I have column A conditional formatted as =D1=1, but I need to be able to compare it to 10 different number in D1, how can this be done, I am using excel '97. thanks
 
if each cell in column A relates to a cell in the same row,but in column B you could use this macro. (to insert rightckick on the sheettab, choose show code and paste the code)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Then
Select Case Target.Value
Case 1: ci = 1
Case 2: ci = 3
Case 3: ci = 5
Case 4: ci = 7
Case 5: ci = 9
Case 6: ci = 11
Case 7: ci = 13
Case 8: ci = 15
Case 9: ci = 17
Case 10: ci = 18
Case Else
End Select
Target.Offset(0, -3).Interior.ColorIndex = ci
End If
End Sub
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Tommy that works! but if I put a letter in column D I get type mismatch, can the be fixed? Thanks
 
Upvote 0
Sorry. I tested it in xl2000 with no problems.
In xl97 this macro will do the job.
Just added a check to see if target.value is numeric

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Then
If IsNumeric(Target.Value) Then
Select Case Target.Value
Case 1: ci = 1
Case 2: ci = 3
Case 3: ci = 5
Case 4: ci = 7
Case 5: ci = 9
Case 6: ci = 11
Case 7: ci = 13
Case 8: ci = 15
Case 9: ci = 17
Case 10: ci = 18
Case Else
End Select
Target.Offset(0, -3).Interior.ColorIndex = ci
End If
End If
End Sub

regards Tommy
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top