How to have a cell change color based on time of day?

biasif

New Member
Joined
Nov 1, 2019
Messages
7
Hi all,
I'm having trouble formatting a cell to change colour depending on time of day.

The cell has no colour to start.
At 8:45 am, I would like the cell colour to change to yellow.
At 9:00 am, I would like the cell colour to change to red.

Is there way to do this with conditional formatting?

Any help is appreciated
frank
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi Biasif,

This does as you ask:

Biasif.xlsx
A
1Rows 2 to 10
2
3
4
5
6
7
8
9
10
11
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A10Expression=(NOW()-INT(NOW()))>=TIME(9,0,0)textNO
A2:A10Expression=AND(NOW()-INT(NOW())>=TIME(8,45,0),(NOW()-INT(NOW()))<TIME(9,0,0))textNO
 
Upvote 0
Thanks Toadstool,
I can't get this to work.
I am selecting the cells range, opening conditional formatting, selecting new rule, then the use formula option.
In the formula window I am copying the expression you provided.

What am I doing wrong?

frank
 
Upvote 0
What am I doing wrong?

I can't see from this end of the internet so let me give you a couple of screenshots and see if they can help.

1635526297265.png


1635526309324.png
 
Upvote 0
The first question must be: "What is the time where you are?"

The cells will not be coloured when midnight arrives and will remain that way until 08:45am when they turn yellow, then at 9:00am they change to red and remain that way until midnight arrives again.
 
Upvote 0
The first question must be: "What is the time where you are?"

The cells will not be coloured when midnight arrives and will remain that way until 08:45am when they turn yellow, then at 9:00am they change to red and remain that way until midnight arrives again.
I am in the eastern time zone. It is 2pm.
 
Upvote 0
Let's check the formula.

Enter
Excel Formula:
=(NOW()-INT(NOW()))>=TIME(9,0,0)
into any cell of your sheet. It should return TRUE

Excel holds dates as integers since 1 Jan 1900 and time as fractions of a day. This formula subtracts the integer of NOW() (the date) from the date and time so leaving a fraction
Enter
Excel Formula:
=(NOW()-INT(NOW()))
into any cell. If it's around 2pm where you are then it should return approximately 0.8119

The TIME does the comparison so enter
Excel Formula:
=TIME(9,0,0)
in a cell. It should return 9:00 AM

If those do as expected then it must be a challenge around the Conditional Format.
 
Upvote 0
Let's check the formula.

Enter
Excel Formula:
=(NOW()-INT(NOW()))>=TIME(9,0,0)
into any cell of your sheet. It should return TRUE

Excel holds dates as integers since 1 Jan 1900 and time as fractions of a day. This formula subtracts the integer of NOW() (the date) from the date and time so leaving a fraction
Enter
Excel Formula:
=(NOW()-INT(NOW()))
into any cell. If it's around 2pm where you are then it should return approximately 0.8119

The TIME does the comparison so enter
Excel Formula:
=TIME(9,0,0)
in a cell. It should return 9:00 AM

If those do as expected then it must be a challenge around the Conditional Format.

The above worked as you stated.
I am trying again. I don't think excel is refreshing properly.
I am using excel at the office, over a network. I don't know if that has anything to do with it but I will try the same formatting
when I get home and will post the result.

Thank you for your help
frank
 
Upvote 0
You're welcome.

Are you sure it's recalculating? Try F9 and see if it works.
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,344
Members
448,956
Latest member
Adamsxl

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