Cell Formatting with a macro...

M

MOC835

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.
 
D

Don Guillett

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
 

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