Colour formatting without macro

JRS

New Member
Joined
Mar 10, 2011
Messages
44
Hi folks,

I'm trying to get my excel spreadsheet to look at column A which has a day count:
Day1
Day2
Day3
...etc...

If the day is an odd number then I would like that row to be coloured with a blue background, if it is an even number then I would like it to be coloured with a yellow background.

Does anyone know how I can do this? Ideally I would like it so the page does this automatically without the need to press a button to run a macro. Again, not sure if I can do this. Please help,

Thanks
JRS
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
if you know how to use a formula in conditional formatting:

For Column A
1) For Odd Days
=IF(MOD($A1,2)=1,TRUE,FALSE)
2) For Even Days
=IF(AND($A1 <> "",MOD($A1,2)=0),TRUE,FALSE)

if you don't know how to use a formula in conditional formatting:
1) Select Column A
2) Home Tab, Styles, Conditional Formatting, Manage Rules
3) New Rule, Use A Formula To Determine Which Cells To Format
3a) =IF(MOD($A1,2)=1,TRUE,FALSE)
3b) Format, Fill, Background Color (Blue for this one)
3c) Hit Okay
4) New Rule, Use A Formula To Determine Which Cells To Format
4a) =IF(AND($A1 <> "",MOD($A1,2)=0),TRUE,FALSE)
4b) Format, Fill, Background Color (Yellow for this one)
4c) Hit Okay
5) Hit Okay
 
Upvote 0
Ganjin, Your code is almost perfect, if I put a number into column A then it works like a dream.

The problem is I need it to work when it literally says "day1" and not just "1"
Is there a way to get it to check just the last digit in cell?

Thanks for your help so far...
 
Upvote 0
Also, I need it to colour the whole row, rather than just the first cell.

Anymore advice would be greatly appreciated...
 
Upvote 0
hmm, assuming that it is always like this:
day1
day2
day101
day202

then, these formulas should work:
=IF(MOD(MID($A1,4,100),2)=1,TRUE,FALSE)
=IF(AND($A1 <> "",MOD(MID($A1,4,100),2)=0),TRUE,FALSE)
 
Upvote 0
ah, that is a simple fix, instead of selecting Column A in the first step:

either ...
select the whole sheet
(the entire row to the absolute limits of the table will be highlighted)
or ...
select Column A and drag to the last relevant Column
(if your data goes from Column A to Column Z, then dragging Column A to Column Z, will allow for a nicer look)
 
Last edited:
Upvote 0
muchos muchos gracias, it works perfectly!!!
:D
Just wish I could figure this stuff out for myself.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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
Back
Top