ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   use the current time to return a value (https://www.excelbanter.com/excel-programming/346737-use-current-time-return-value.html)

sd

use the current time to return a value
 
Simple formula? if the time is =07:00:00<15:00:00, G$1. = 1 if time
=15:00:00 < 23:00:00 G$1 = 2 if Time =23:00:00 < 07:00:00 G$1 = 3


I have tried to do this a few different ways and have been
unsuccessful. Could someone help please?


Pete[_26_]

use the current time to return a value
 
I assume your time is in cell A1 (change to suit). Enter the following
formula in cell G1:

= IF( OR(A1 23:00:00, A1 < 07:00:00), 3 ,IF( A1 15:00:00, 2, 1 ) )

(Spaces not really necessary - just easier to read)

Pete


Pete[_26_]

use the current time to return a value
 
Sorry, the first greater than should be greater than or equal to,

i.e. change to = for the comparison with 23:00:00

Pete


Tom Ogilvy

use the current time to return a value
 
If that doesn't work, try it like this:

= IF( OR(A1 = TIMEVALUE("23:00"), A1 < TIMEVALUE("07:00")), 3,IF( A1 =
TIMEVALUE("15:00"), 2, 1 ) )

--
Regards,
Tom Ogilvy

"Pete" wrote in message
oups.com...
I assume your time is in cell A1 (change to suit). Enter the following
formula in cell G1:

= IF( OR(A1 23:00:00, A1 < 07:00:00), 3 ,IF( A1 15:00:00, 2, 1 ) )

(Spaces not really necessary - just easier to read)

Pete




tony h[_5_]

use the current time to return a value
 

The other thing that can confuse is that if the cell A1 is formatted a
TIME it will display a time even though it has a date. Therefore yo
may need to take the fractional part of cell A1 which can be done b
substituting TIMEVALUE(A1) for the A! in the previous answer.

you can see this in :
timevalue(time)=time which is true and
timevalue(now)=now which is false

hope this help

--
tony
-----------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=48874



All times are GMT +1. The time now is 12:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com