Conditional Formatting based on Current Time ?

Aitch

Board Regular
Joined
Jan 27, 2019
Messages
119
Office Version
  1. 2010
Platform
  1. Windows
ft1RbJ77
Excel1.jpg



I'm using the NOW function to give the time in cell A1

I thought it would be easy to highlight the row which corresponds to the time, by EXACT matching A1 to the column B... but it's not working!

What's the best way to get this to work?

Thanks for your help!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Ultimately NOW() is a floating-point number, and any quant will tell you, you shouldn't ever do exact comparisons with floating-point numbers, even with zero, because computers always have rounding errors. The general way to compare floating-point numbers is to subtract them and see if the absolute value of the difference is within a small tolerance.

So with numbers you would not use "=$A$1=B1" but instead "=ABS($A$1-B1)<0.00001" to determine equality to the fifth decimal place; with times you should use "=ABS($A$1-B1)<TIME(0,0,0.1)" to determine precision within a tenth of a second.


Note that I've used absolute addressing with $A$1, but not B1; this is so that when you copy formats downward, including conditional ones, $A$1 doesn't change, but B1 does.
 
Upvote 0
You can compare the text of both hours

=TEXT($A$1,"hh:mm")=TEXT(B3,"hh:mm")




For the time to update and move the highlight cell you can put the following code in the events of your sheet

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.Volatile
    Calculate
    DoEvents
End Sub

Every time you select any cell the time in A1 will be updated
 
Upvote 0
Use this formula:

=TEXT($A$1,"hh:mm")=TEXT($B3,"hh:mm")



It is important that in $B3 only have & before B

Apply To:
=$1:$1048576
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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