# Excel - Macros - Coloring Cells

#### r_nj

##### New Member

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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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.

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

Thnaks...

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

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

Thanks Greg! It worked...
How do I color the lowest 2 numbers... do I use "SMALL"

Bingo.

Greg, I tried =(A1>=SMALL(MyRange,2)) and it did not work -- it colored all the cell but one.

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}

Greg - thanks - I had not changed the ">" Have a nice weekend...

Replies
5
Views
162
Replies
4
Views
284
Replies
4
Views
119
Replies
1
Views
117
Replies
1
Views
63

Threads
1,214,745
Messages
6,121,283
Members
449,021
Latest member
bob_messenger

### 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

### 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