Basic idea. Incorporate into a worksheet_change event for it to be
automatic.
Sub selectcaseformatting()
Select Case ActiveCell.Value
Case 1: x = 3
Case 22: x = 5
Case 31: x = 6
Case 46: x = 8
Case Else
End Select
ActiveCell.Interior.ColorIndex = x
End Sub
--
Don Guillett
SalesAid Software
(E-Mail Removed)
"MOC835" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Related to a previous topic.
>
> I have a worksheet that uses conditional formatting. However, I need
> to add a 4th condition. I need to code a macro that checks the
> content of a cell, and then changes the formating (color) of a range
> of cells if the condition is met.
>
> For example if cell M1 is populated with an 'X', then I want excel to
> change the color of the cells (pattern) for the range A1:M1.
>
> Basically, the macro will check for values in the M column and
> highlight all the cells in the intersecting row.
>
> I used conditional formating to perform other tasks, but since Excel
> only supports 3 conditions (4 if you count the initial/default
> condition) now I need a macro!
>
> Please help.
>