Excel Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know if you can write a macro in Excel that will result in
certain cells being colored in if a specific condition exists? I know you can
write for the condition, but can the product actually go out and color a
specific cell say red if the correct condition exists?
Thanks,
 
You don't need a macro, you can do that with Conditional Formatting
(Format>Conditional Formatting)

--

HTH

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

Sure. Here's some example code.

If Range("A1").Value = "Fred" Then
Range("A3").Interior.ColorIndex = 3
Else
Range("A3").Interior.ColorIndex = xlNone
End If

Typically, that would be used in the worksheet's change event so that when
A1 is changed, the color of A3 is then automatically changed. As an event,
it could be written exactly the same, just wrapped in the event sub.

HTH,
Bernie
MS Excel MVP
 

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

Back
Top