Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF statement Help

Is there a way I can do the following to force a date
change according to a certain time. In cell b5 I have =Now
(), and that returns todays date. If the time is between
midnight and six am I would like the date to go back one
day, such as =Now()-1.

Even if I have to make a button to run macro that would
be OK. I just can't figure out the IF statement that
would compare the times.

I want it to read something like this; if the time is
between 00:00:00 and 06:00:00 then Now()-1 else Now()

Thanks in advance for your help

John G
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default IF statement Help

John;

Create a macro that contains:

If hour(now)<6 then Range("A1") = Date -1

Else Range("A1") = Date

End If





-----Original Message-----
Is there a way I can do the following to force a date
change according to a certain time. In cell b5 I have =Now
(), and that returns todays date. If the time is between
midnight and six am I would like the date to go back one
day, such as =Now()-1.

Even if I have to make a button to run macro that would
be OK. I just can't figure out the IF statement that
would compare the times.

I want it to read something like this; if the time is
between 00:00:00 and 06:00:00 then Now()-1 else Now()

Thanks in advance for your help

John G
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IF statement Help

=IF(HOUR(NOW())<6,NOW()-1,NOW())

--
Regards,
Tom Ogilvy

John G wrote in message
...
Is there a way I can do the following to force a date
change according to a certain time. In cell b5 I have =Now
(), and that returns todays date. If the time is between
midnight and six am I would like the date to go back one
day, such as =Now()-1.

Even if I have to make a button to run macro that would
be OK. I just can't figure out the IF statement that
would compare the times.

I want it to read something like this; if the time is
between 00:00:00 and 06:00:00 then Now()-1 else Now()

Thanks in advance for your help

John G



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF statement Help

Thank You very much for the reply Tom & GJones
-----Original Message-----
=IF(HOUR(NOW())<6,NOW()-1,NOW())

--
Regards,
Tom Ogilvy

John G wrote in

message
...
Is there a way I can do the following to force a date
change according to a certain time. In cell b5 I have

=Now
(), and that returns todays date. If the time is

between
midnight and six am I would like the date to go back

one
day, such as =Now()-1.

Even if I have to make a button to run macro that

would
be OK. I just can't figure out the IF statement that
would compare the times.

I want it to read something like this; if the time is
between 00:00:00 and 06:00:00 then Now()-1 else Now()

Thanks in advance for your help

John G



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
SUMIF statement with AND statement Eric D Excel Discussion (Misc queries) 2 July 14th 08 07:24 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


All times are GMT +1. The time now is 04:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"