ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Macros (https://www.excelbanter.com/excel-programming/323927-excel-macros.html)

Nonsequitr

Excel Macros
 
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,

R.VENKATARAMAN

Excel Macros
 
problem not clear. however use format-conditional formatting


Nonsequitr wrote in message
...
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,




Bob Phillips[_6_]

Excel Macros
 
You don't need a macro, you can do that with Conditional Formatting
(FormatConditional Formatting)

--

HTH

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


"Nonsequitr" wrote in message
...
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,




Bernie Deitrick

Excel Macros
 
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

"Nonsequitr" wrote in message
...
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,





All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com