Calculating scheduled minutes in a time block

sparkhil

New Member
Joined
Jul 23, 2014
Messages
4
I am trying to take scheduled start time and scheduled duration in h:mm and auto populate the scheduled minutes in the corresponding time blocks.

Example:
Schedule ID
Start TimeDuration8AM9AM10AM11AM12PM1PM2PM3PM4PM
Schedule A8:45 AM00:03:0015
60
60
45





Schedule B12:00 PM00:04:00



60
60
60
60

Schedule C3:00 PM00:01:15






60
15

<tbody>
</tbody>


The first 3 columns are derived from a data table and I am trying to auto populate the minutes scheduled in the time blocks using conditional formatting or some other mechanism.

Any insight would be greatly appreciated.

I'm using Excel 2010
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
This should get you started.

Sheet2

BCDEFGHIJKLM
2Schedule IDStartDuration8:009:0010:0011:0012:0013:0014:0015:0016:00
3Schedule A8:453:001560604500000
4Schedule B12:004:000000606060600
5Schedule C15:001:1500000006015

<tbody>
</tbody>

Worksheet formulas
CellFormula
E3=ROUND(MAX(0, (MIN($C3+$D3, F$2)-MAX(E$2, $C3))*24*60), 0)

<tbody>
</tbody>

<tbody>
</tbody>


Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4.8

Notes
* Copy cell E3 for the entire range
* ROUND() is added to avoid tiny fractions, like 0.0000000015
* Use number format to avoid 0 display, or an IF function if you prefer
* The *24*60 part is to convert Excel's Date/Time value to minutes (24 hours in a day, 60 minutes in an hour)
* You can change the intervals at the top as you wish, to get the correct result (for example, try changing 9:00 to 9:30), however be mindful that they don't overlap (e.g. changing 9:00 to 10:30 still works, but doesn't make sense).

Good luck.
 
Last edited:
Upvote 0
One more question on the formula, I hope someone can help with...is there a way to display the zero value fields as a blank, instead of 0?
 
Upvote 0
In the Notes above:
* Use number format to avoid 0 display, or an IF function if you prefer

For the number format option, format your cells as Custom, for example 0;-0;;@

This will preserve the 0 result, but display a blank instead.

for the IF option, you would do this

=IF(formula=0, "", formula)

Where formula is the one from E3 above: =ROUND(MAX(0, (MIN($C3+$D3, F$2)-MAX(E$2, $C3))*24*60), 0)

This will display a blank, therefore not recognize those cells as a number (zero).


Your choice will determine how these cells are used in certain calculations, such as AVERAGE() function.
 
Upvote 0
In the Notes above:


For the number format option, format your cells as Custom, for example 0;-0;;@

This will preserve the 0 result, but display a blank instead.

for the IF option, you would do this

=IF(formula=0, "", formula)

Where formula is the one from E3 above: =ROUND(MAX(0, (MIN($C3+$D3, F$2)-MAX(E$2, $C3))*24*60), 0)

This will display a blank, therefore not recognize those cells as a number (zero).


Your choice will determine how these cells are used in certain calculations, such as AVERAGE() function.

I went with the =IF(formula=0, "", formula) option, as I need to count non zero values in a pivot table and this seemed like the best way to achieve that. I thought we had it nailed, but noticed some anomalies where a 0 is returned in the column to the left of the first numeric value. For some reason this does not happen on all rows.

Example:
Integration/ Report NameScheduled Start TimeAvg Run DurationEnd TimeDay of Week12:01 AM12:30 AM1:00 AM1:30 AM2:00 AM2:30 AM3:00 AM3:30 AM4:00 AM4:30 AM5:00 AM5:30 AM6:00 AM6:30 AM7:00 AM7:30 AM
INT2011:00 AM4:27:005:27 AMDaily303030303030303027
INT2023:30 AM2:17:005:47 AMMonday3030303017
INT2034:00 AM0:36:004:36 AMTuesday0306
INT2046:00 AM0:45:006:45 AMWednesday3015

<tbody>
</tbody>

The formula I'm using is =IF(MAX(0,(MIN($B2+$C2,J$1)-MAX(I$1,$B2))*48*30)=0,"",ROUND(MAX(0,(MIN($B2+$C2,J$1)-MAX(I$1,$B2))*48*30),0))

Any insight on how I might modify the formula above to eliminate the 0 value population would be greatly appreciated, as this inflates the column instance counts (3:30 AM should have an instance count of 2, but returns 3 due to the 0 value).
 
Upvote 0
I did not get that result; my 3:30AM for INT203 is showing a blank.

However, I suspect the problem might be that you're using the ROUND() function in the FALSE portion of the IF statement, rather than the condition. Try this instead (using your cell addresses):


=IF(ROUND(MAX(0,(MIN($B2+$C2,J$1)-MAX(I$1,$B2))*48*30),0)=0,"",MAX(0,(MIN($B2+$C2,J$1)-MAX(I$1,$B2))*48*30))


Again, the problem might be tiny fractions due to binary rounding issues. Because time is a fraction of 1, it can result in some really small values, and instead of a 0, you might be getting results such as 0.0000000015. The condition part of the IF function is looking for an exact 0, and if the time calculation evaluates to these fractional values instead, the FALSE portion of the IF statement is returned. That part returns a number, regardless of the rounding.

If instead you move the ROUND() function to the condition part of the IF statement, you avoid these rounding errors, and get the correct results.

That's my hunch. Hope it works out for you, post back if not.
 
Upvote 0

Forum statistics

Threads
1,215,730
Messages
6,126,529
Members
449,316
Latest member
sravya

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