Help with excel formulas for adding time but keeping all time between 9am and 6pm...

gunder1225

New Member
Joined
Aug 25, 2017
Messages
1
Hi!

I'm not too familiar with excel formulas, and I've been banging my head on my keyboard trying to figure this out. I'm trying to create a calculator where someone inserts a time (any time, between (12:00 am - 11:59 pm) and then the calculator adds 2 and a half hours to that time, then two and a half hours would be added two more times.

Ex1: Person enters 9:00 am, calculator adds 2:30, so it's 11:30 am, then the next cell it adds another 2:30, so it's 2:00 pm, and then the next cell it adds the final 2:30, so it's 4:30 pm.

The first tricky part for me is trying to keep times between 9 am and 6 pm (work hours). If the person entering the time enters 8:00 am or 6:24 pm, the time should add the 11:30 to 9:00 am, so that the first calculated time is 11:30 am (the start of the work day).

The second tricky part is if the 2:30 added to a time passes 6:00 pm, to then add that leftover time to 9:00 am.

Ex2: Person enters 5:30 pm, plus the 2:30 would be 8:00 pm, but instead, I want it to read as 11:00 am.

My layout in excel as in columns A and B and looks as follows:
A1 (header) B1 (header)
A2 (Step 1 - Time Entered) B2 (Time entered)
A3 (Step 2) B3 (formula)
A4 (Step 3) B4 (formula)
A5 (Step 4) B5 (formula)

In B3 I entered a long messy If/And, it works perfectly, the issue is I cannot get the next two steps to work the same way, also I'm SURE there's a slightly easier, less messy way to accomplish this

Formula entered into B3: =IF(AND(B2>=H100,B2<=A100),A99,IF(AND(B2>A100,B2<c100),b2+e100,if(and(b2>C100,B2<b100),d100-b100+a100,if(and(b2>=B100,B2<b99),a99))))

List of 99/100 cell references in order they appear in formula:
H100 = 12:00 AM
A100 = 9:00 AM
A99 = 11:30 AM
C100 = 3:30 PM
E100 = 2:30 (no am or pm)
B100 = 6:00 PM
D100 = B2 (the time manually entered) + 2:30
B99 = 11:59 PM

If you've taken the time to read this loooong post I really appreciate it! And if anything is unclear, please let me know!

And thank you in advance!</b99),a99))))
</b100),d100-b100+a100,if(and(b2></c100),b2+e100,if(and(b2>
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Welcome to the forum.

I think I've got this right, even though there were several errors in your post. Copy B6:D6 downwards.

ABCD
1span (hours)2.5
2start9:00:00 AM
3end6:00:00 PM
4
5EntryStep 1Step 2Step 3
64:00:00 AM11:30:00 AM2:00:00 PM4:30:00 PM
78:00:00 AM11:30:00 AM2:00:00 PM4:30:00 PM
88:59:00 AM11:30:00 AM2:00:00 PM4:30:00 PM
99:00:00 AM11:30:00 AM2:00:00 PM4:30:00 PM
1012:00:00 PM2:30:00 PM5:00:00 PM11:30:00 AM
111:00:00 PM3:30:00 PM6:00:00 PM11:30:00 AM
121:01:00 PM3:31:00 PM11:30:00 AM2:00:00 PM
132:00:00 PM4:30:00 PM11:30:00 AM2:00:00 PM
143:00:00 PM5:30:00 PM11:30:00 AM2:00:00 PM
155:00:00 PM11:30:00 AM2:00:00 PM4:30:00 PM
1611:00:00 PM11:30:00 AM2:00:00 PM4:30:00 PM

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet25

Worksheet Formulas
CellFormula
B6=IF(A6<$B$2,$B$2+$B$1/24,IF((A6+$B$1/24)>$B$3,$B$2+$B$1/24,A6+$B$1/24))
C6=IF(B6<$B$2,$B$2+$B$1/24,IF((B6+$B$1/24)>$B$3,$B$2+$B$1/24,B6+$B$1/24))
D6=IF(C6<$B$2,$B$2+$B$1/24,IF((C6+$B$1/24)>$B$3,$B$2+$B$1/24,C6+$B$1/24))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,216,574
Messages
6,131,492
Members
449,653
Latest member
aurelius33

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