Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default macro for formatting/colour cells

is there a way to use a macro for conditional formatting?

I have to colour a cell if the value met one of 2 conditionals: "TOP" or
"LOW".

in Sheet 1, I have all the values (E6:E256)
...these values in sheet1 are actually formulas pulling from other sheets
in the same book.
in Sheet 2, I have whether those value are TOP (T6:T256) or LOW (U6:U256)

sample:
E6 in sheet1 has a value of 98% and T6 in sheet2 marks it as TOP so, E6 in
sheet1 should be green
E7 in sheet1 has a value of 5% and U7 in sheet2 marks it as LOW so, E7 in
sheet1 should be red

any ideas how to do this would be greatly appreciate it!

cheers,
Mayte
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default macro for formatting/colour cells

You can call up the Conditional Formatting dialogs box in VBA with:

CF = Application.Dialogs(xlDialogConditionalFormatting) .Show

You can also use If statements to do the coloring like:

If ActiveSheet.Range("E6").Value = .98 Then
Range("E6").Interior.ColorIndex = 10
End If

The advantage of using the CF color is that it automatically reverts to no
fill if the criteria is not met. The disadvantage is that if you want to
write code based on the color of the cell, it gets pretty complex. The CF
interior color is on a different object level than the range interior color
and is not necessarily visible even though the CF setting indicates the
color. To get a true color value for CF, you have to evaluate whether the
cell value meets the CF criteria to turn the color on.

"Mayte" wrote:

is there a way to use a macro for conditional formatting?

I have to colour a cell if the value met one of 2 conditionals: "TOP" or
"LOW".

in Sheet 1, I have all the values (E6:E256)
...these values in sheet1 are actually formulas pulling from other sheets
in the same book.
in Sheet 2, I have whether those value are TOP (T6:T256) or LOW (U6:U256)

sample:
E6 in sheet1 has a value of 98% and T6 in sheet2 marks it as TOP so, E6 in
sheet1 should be green
E7 in sheet1 has a value of 5% and U7 in sheet2 marks it as LOW so, E7 in
sheet1 should be red

any ideas how to do this would be greatly appreciate it!

cheers,
Mayte

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default macro for formatting/colour cells

thanks!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
conditionally formatting colour of cells trishb Excel Discussion (Misc queries) 2 December 12th 09 01:14 AM
formatting colour in cells when one cell contains a character wilko[_2_] Excel Worksheet Functions 1 September 14th 09 01:27 AM
excel 2003 - formatting cells - colour Bernard Liengme Excel Worksheet Functions 0 January 19th 09 02:40 PM
NEED MACRO FOR COLOUR BY CONDITIONAL FORMATTING K[_2_] Excel Programming 9 December 16th 07 05:44 PM
Colour and Pattern Formatting Cells Dave M[_2_] Excel Programming 3 March 29th 06 04:31 PM


All times are GMT +1. The time now is 09:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"