Excel - Macros - Coloring Cells

r_nj

New Member
Joined
Nov 11, 2005
Messages
10
:confused:
I would like to get some help to create a macro as I have just joined a firm as a Jr. Analyst - I am still learning Macros - please help..

I would like to change the color of the cell based on the following:

For Column A,B,D,E,L : color highest 2 numbers- RED, lowest 2 numbers -yellow


For column C, if the % is 50% and above then green, if between 50.1% and 45% then blue, if lower than 44.9% then - black
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
Office Version
  1. 365
Platform
  1. Windows
You don't actually need macros for this, you can use Format>Conditional Formatting....

I'm afraid I can't give any more specific help as I'm about to go offline, but I'm sure somebody else will be along on a minute.
 

Crow_23

Board Regular
Joined
Feb 17, 2005
Messages
183
Just check out "Conditional Formatting" in the posts....all you need for the job. If you want it tied to a macro you are already running there should be stuff on that as well under same topic. Post back if you need further help.

Ed
 

r_nj

New Member
Joined
Nov 11, 2005
Messages
10
Thnaks...

Conditional Formatting does not allow me to color the highest 2 numbers &
the lowest 2 numbers...
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022

ADVERTISEMENT

r_nj said:
Conditional Formatting does not allow me to color the highest 2 numbers & the lowest 2 numbers...
Yes it does. [...very tempted to be a wise guy and stop here... :wink: ]

Here's how: Select the cells of interest and name them. In my example I just named them MyRange. Select the range and set CF to Formula Is and =(A1>=LARGE(MyRange,2)) changing "A1" to be the address of the first cell of your range.

HTH
 

r_nj

New Member
Joined
Nov 11, 2005
Messages
10
Thanks Greg! It worked...
How do I color the lowest 2 numbers... do I use "SMALL"
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022

ADVERTISEMENT

Bingo.
 

r_nj

New Member
Joined
Nov 11, 2005
Messages
10
Greg, I tried =(A1>=SMALL(MyRange,2)) and it did not work -- it colored all the cell but one.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
Make sure "A1" is your activecell when you enter the formula. If it isn't Excel can get really creative in interpreting the formula. {edit}By this I mean that whatever the formula that you type in, you need the address to reference per the active cell. If your active cell is AQ1432 and you want the CF formula to look at the cell for which you are applying the CF then your CF formula had better reference AQ1432. (Did this additional comment clarify or occult?){/edit}
 

r_nj

New Member
Joined
Nov 11, 2005
Messages
10
Greg - thanks - I had not changed the ">" Have a nice weekend...
:biggrin:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,081
Messages
5,857,239
Members
431,865
Latest member
ExcellNewbie98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top