Format Column based on time slot and current time

triumph

New Member
Joined
Sep 6, 2013
Messages
4
I am struggling to get a column to be formatted based on the date and time. My sheet is a planner sheet, broken down into 3 hr segments. I want to highlight the column with red borders applicable to the time the document is opened. I have NOW() in A1, F2 is 04/09/2019 00:00:00, F3=F2+0.125. I would like to highlight from row 1 to row 87.

I have tried =NOW() - - AND(<=,=>) - - IF all in several iterations, I am now stumped. Any help appreciated.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You will not get it to work for time opened with a formula. The NOW() function is volatile, so it will change to the current time whenever the sheet is recalculated.

If you want it fixed to the time that the file is opened then I would suggest creating a timestamp with a workbook open event (vba / macro), then using that as a reference point. Is that something that you would be able to use?
 
Upvote 0
Try this code in the vba workbook module,
Code:
Private Sub Workbook_Open()
ActiveWorkbook.Names.Add Name:="TimeNow", RefersToR1C1:=[CEILING(NOW(),1/8)]
End Sub
which will give you a reference time when the workbook is opened rounded up to the nearest 3 hour point (0:00, 03:00, 06:00, etc.).

You can then use something like =F3=TimeNow to compare the times in column F. Note that as it stands, this will compare date and time, not just time. If the times in the sheet are only time (no date) then the INT function will need to be incorporated as well.
 
Upvote 0
You will not get it to work for time opened with a formula. The NOW() function is volatile, so it will change to the current time whenever the sheet is recalculated.

If you want it fixed to the time that the file is opened then I would suggest creating a timestamp with a workbook open event (vba / macro), then using that as a reference point. Is that something that you would be able to use?

Not sure I need to go that deep. The time doesn't need to be a fixed point, I need the formatting to reflect the time the document is opened. so NOW() would be a sufficient reference point surely.
 
Upvote 0
NOW() will always be the current time, not the time the workbook was opened.

Type =NOW() into a cell and format it as hh:mm:ss

Type somehting into another cell, the time of NOW() will change. Double click between 2 colums so that the cells autofit to the data, NOW() will change. Apply a filter to your data, NOW() will chage. It will not stay fixed at the time the workbook was opened. So, if you want it fixed, then yes, you do need to go that deep.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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