PC Review


Reply
Thread Tools Rate Thread

Cell colouring macro.

 
 
ceab
Guest
Posts: n/a
 
      12th Sep 2007
I have a row with a bunch of numbers from 1 to 10.
I need a macro (or something) that colours the cell green for numbers less
than or equal to 5, yellow for 6-8 and red for 9-10.
How can I do this?

Any help appreciated.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      12th Sep 2007
Look up 'Conditional Formatting'. You can use the formula option to determine
the color required.

Regards,

OssieMac

"ceab" wrote:

> I have a row with a bunch of numbers from 1 to 10.
> I need a macro (or something) that colours the cell green for numbers less
> than or equal to 5, yellow for 6-8 and red for 9-10.
> How can I do this?
>
> Any help appreciated.
>
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      12th Sep 2007
It sounds you could use format|conditional formatting to do this.

You can read Debra Dalgleish's notes starting here:
http://contextures.com/xlCondFormat01.html

ceab wrote:
>
> I have a row with a bunch of numbers from 1 to 10.
> I need a macro (or something) that colours the cell green for numbers less
> than or equal to 5, yellow for 6-8 and red for 9-10.
> How can I do this?
>
> Any help appreciated.


--

Dave Peterson
 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      12th Sep 2007
>I have a row with a bunch of numbers from 1 to 10.
> I need a macro (or something) that colours the cell
> green for numbers less than or equal to 5, yellow for
> 6-8 and red for 9-10.
> How can I do this?


Select all of the cells in the row that will need to have this functionality
(if you are not sure, and these numbers are the only ones that will be in
the row, then select the entire row). Note which cell is the highlighted one
(it will be the non-shaded one)... for my example, I am assume we are
talking about Row A and that A1 is the highlighted cell (you will use the
address for the highlighted cell in your own selection in place of the A1
that I use). With the range selected, click on Format/ConditionalFormatting
in Excel's menu bar. Click the Add button twice on the dialog box that
appears (so that you will see three "Conditions" listed. In the first combo
box in each condition, select "Formula Is". Put these formulas into the
indicated "Conditions"...

Condition 1: =AND(A1<>"",A1<=5)

Condition 2: =AND(A1<>"",A1<=8)

Condition 3: =AND(A1<>"",A1<=10)

Next, click the format button for Condition 1, click the Patterns tab on the
dialog box that appears and select the shade of green that you want the cell
to be colored in if the value is less than or equal to 5. Hit OK. Do the
same thing for Condition 2 (selecting a shade of yellow) and Condition 3
(selecting a shade of red). Once you have finished that, click OK on the
Conditional Formatting screen and the cells you highlighted will color in
correctly when the numbers you indicated are entered into them.

Rick


 
Reply With Quote
 
=?Utf-8?B?bGVhcm5pbmcgcXVpY2tseQ==?=
Guest
Posts: n/a
 
      12th Sep 2007
Can this be done with multiple rows? I have a spreadsheet that is finding the
max number in a row for each row. I want for each row the highlight the max
number. EG:E4=max(m4:ap4) and whatever number is populated in column E I want
that number in columns m through ap for that particular row to highlight.

Thank you

"Rick Rothstein (MVP - VB)" wrote:

> >I have a row with a bunch of numbers from 1 to 10.
> > I need a macro (or something) that colours the cell
> > green for numbers less than or equal to 5, yellow for
> > 6-8 and red for 9-10.
> > How can I do this?

>
> Select all of the cells in the row that will need to have this functionality
> (if you are not sure, and these numbers are the only ones that will be in
> the row, then select the entire row). Note which cell is the highlighted one
> (it will be the non-shaded one)... for my example, I am assume we are
> talking about Row A and that A1 is the highlighted cell (you will use the
> address for the highlighted cell in your own selection in place of the A1
> that I use). With the range selected, click on Format/ConditionalFormatting
> in Excel's menu bar. Click the Add button twice on the dialog box that
> appears (so that you will see three "Conditions" listed. In the first combo
> box in each condition, select "Formula Is". Put these formulas into the
> indicated "Conditions"...
>
> Condition 1: =AND(A1<>"",A1<=5)
>
> Condition 2: =AND(A1<>"",A1<=8)
>
> Condition 3: =AND(A1<>"",A1<=10)
>
> Next, click the format button for Condition 1, click the Patterns tab on the
> dialog box that appears and select the shade of green that you want the cell
> to be colored in if the value is less than or equal to 5. Hit OK. Do the
> same thing for Condition 2 (selecting a shade of yellow) and Condition 3
> (selecting a shade of red). Once you have finished that, click OK on the
> Conditional Formatting screen and the cells you highlighted will color in
> correctly when the numbers you indicated are entered into them.
>
> Rick
>
>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      13th Sep 2007
Yes, you can apply Conditional Formatting across multiple rows, multiple
columns and both multiple rows and multiple columns together. I'm not 100%
sure about what you are asking (what is EG:E4?), but let me take a guess.
You want to highlight two different things in **each** row... the maximum
value and those values that are equal to the value in column E of the same
row. Because the format for these will be different, you will need to decide
how to handle the situation when a cell contains a value that is equal to
the value in column E of the same row and that value also happens to be the
maximum in the row also.

Here is what I came up with. The maximum value(s) will be highlighted in
red, the value(s) equal to the the value in column E of the same row will be
highlighted in green and those cells that are both a maximum and equal to
the column E value will be hatched in the colors red and green.

Okay, select all the cells from column M through column AP and down for as
many rows as you will need to eventually handle. With the range selected (do
it so M1 is the highlighted cell in this range), click on
Format/ConditionalFormatting in Excel's menu bar. Click the Add button twice
on the dialog box that appears (so that you will see three "Conditions"
listed. In the first combo box in each condition, select "Formula Is". Put
these formulas into the indicated "Conditions"...

Condition 1: =AND(M1=$E1,M1=MAX($M1:$T1),$M1<>"")

Condition 2: =AND($M1=MAX($M1:$T1),$M1<>"")

Condition 3: =AND($M1=$E1,$M1<>"")

Next, click the Format button for Condition 1, click the Patterns tab on the
dialog box that appears and select a cross-hatch pattern and (while the
pattern dialog is open) pick a light red color for the cross-hatch color;
then click OK and pick a light green color from the Cell shading area for
the cell's background color; finally, click OK to lock in that format. Next,
click the Format button for Condition 2 and pick the same light red color
you used in Condition 1; then click OK. Do the same for Condition 3, but
this time select the same light green color you used in Condition 1. Once
you have finished that, click OK on the Conditional Formatting screen and
the cells you highlighted will color in as I describe in the beginning of
this process.

Rick



"learning quickly" <(E-Mail Removed)> wrote in
message news:063CBDA3-2E25-48E5-8CDD-(E-Mail Removed)...
> Can this be done with multiple rows? I have a spreadsheet that is finding
> the
> max number in a row for each row. I want for each row the highlight the
> max
> number. EG:E4=max(m4:ap4) and whatever number is populated in column E I
> want
> that number in columns m through ap for that particular row to highlight.
>
> Thank you
>
> "Rick Rothstein (MVP - VB)" wrote:
>
>> >I have a row with a bunch of numbers from 1 to 10.
>> > I need a macro (or something) that colours the cell
>> > green for numbers less than or equal to 5, yellow for
>> > 6-8 and red for 9-10.
>> > How can I do this?

>>
>> Select all of the cells in the row that will need to have this
>> functionality
>> (if you are not sure, and these numbers are the only ones that will be in
>> the row, then select the entire row). Note which cell is the highlighted
>> one
>> (it will be the non-shaded one)... for my example, I am assume we are
>> talking about Row A and that A1 is the highlighted cell (you will use the
>> address for the highlighted cell in your own selection in place of the A1
>> that I use). With the range selected, click on
>> Format/ConditionalFormatting
>> in Excel's menu bar. Click the Add button twice on the dialog box that
>> appears (so that you will see three "Conditions" listed. In the first
>> combo
>> box in each condition, select "Formula Is". Put these formulas into the
>> indicated "Conditions"...
>>
>> Condition 1: =AND(A1<>"",A1<=5)
>>
>> Condition 2: =AND(A1<>"",A1<=8)
>>
>> Condition 3: =AND(A1<>"",A1<=10)
>>
>> Next, click the format button for Condition 1, click the Patterns tab on
>> the
>> dialog box that appears and select the shade of green that you want the
>> cell
>> to be colored in if the value is less than or equal to 5. Hit OK. Do the
>> same thing for Condition 2 (selecting a shade of yellow) and Condition 3
>> (selecting a shade of red). Once you have finished that, click OK on the
>> Conditional Formatting screen and the cells you highlighted will color in
>> correctly when the numbers you indicated are entered into them.
>>
>> Rick
>>
>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colouring cell if it has a specific date Shivam.Shah Microsoft Excel Programming 1 18th Feb 2010 08:43 PM
colouring cell KHAN Microsoft Excel Misc 2 2nd Aug 2008 09:42 PM
Excel Macro for colouring cells Flash Microsoft Excel Misc 2 13th Jul 2006 06:18 PM
Automatic cell colouring =?Utf-8?B?Q2hyaXMwMTYyMw==?= Microsoft Excel Worksheet Functions 1 9th May 2006 02:55 PM
colouring a cell andy617 Microsoft Excel Programming 2 11th Jan 2006 03:30 PM


Features
 

Advertising
 

Newsgroups
 


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