IF statement adding a day to a date from 12:00am - Help!

MurraySMTH

Board Regular
Joined
Jun 30, 2020
Messages
81
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am trying to solve a simple IF statement by adding one day to a date from a cell containing time.

=IF(L3>Time(12,00,0)Datevalue(J3+1))

So if L3 is higher that 12:00am add one day to the date in J3

If this is not the case, no change to date.

Thank you for any effort provided! Love this forum.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
What about using an IF statement to just read the "AM" in column L.

So if L3 = AM add one day to column J.
 
Upvote 0
MurrarySMTH,

You need to take into account what Mark said. A cell in Excel can either have:
1. A hard-coded value
- or -
2. A formula
but it can NEVER have both simultaneously!

So, you either need another cell, or you need to use VBA.
 
Upvote 0
MurrarySMTH,

You need to take into account what Mark said. A cell in Excel can either have:
1. A hard-coded value
- or -
2. A formula
but it can NEVER have both simultaneously!

So, you either need another cell, or you need to use VBA.


Got it. Any tips for this to be a VBA?
 
Upvote 0
You need to tell us exactly how it should work. A lot of it depends on how data is entered into the worksheet.

There are basically two different kinds of VBA code that could be applied here.
1. "Event Procedure" VBA code is VBA code that runs automatically upon some "event" happening. In most cases like this, that would be the manual update of a certain cell, column, or row. So if someone where entering those times into those columns, you could have the code automatically run whenever someone manually updates the value in column L.
2. The other kind is just VBA code that you run manually when you want (what people often call "Macros"). So let's say that you are opening a file that has all the data in it, and you want it to run against all the data at once. Then you just select the Macro and run it whenever you like.
 
Upvote 0
I am wondering if the answer isn't to simply add another column for ending date (that could be a formula then)? Otherwise, how will you keep track if the correction was applied or not?
 
Upvote 0
Rick, Yes I think that might be the answer.

Joe,

I am running a report and copy/paste data... the report is designed to give timespans for shifts. If the timespan in column L exceeds 12:00am i would need it to ADD the date by one day to column J.

This would follow a macro.
 
Upvote 0
Rick, Yes I think that might be the answer.
Yes, that is what I was referring to when I said you either need another cell or VBA.

If that works for you, I would go with that approach, as it is simpler. You simply put the formula Rick gave you in some blank, unused column on your sheet.
You can call it whatever you like, "Adjusted End Date", or something like that.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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