Identifying which date range includes a particular hour.

AntBlabby8

Board Regular
Joined
Apr 18, 2002
Messages
200
I have a table of data for hours worked, beginning time and ending time. Many overlap. I need to create a table that counts the number of people at work, at any given hour of the day, in one hour intervals, e.g. 9am-10am, noon-1pm, 10pm-11pm, etc. I thought I could add columns across the raw data, with each column header representing one hour segment. But I'd need to have a formula for each individual that looks at the range of the hours worked (e.g., 8:00am-Noon, Noon-8pm, etc.) and then to lookup a a time at the top of the column fell within the range of their start and finish time and says True or false. This is really a thorny one, and I'm going to have to do it every week for 1800 people!!! Help!

NameStart TimeEnd Time12:01am-1:00am1:01am-2:00am2:01am-3:00am3:01am-4:00am4:01am-5:00am5:01am-6:00am6:01am-7:00am7:01am-8:00am8:01am-9:00am9:01am-10:00am10:01am-11:00am
Amy11:00:00 AM7:30:00 PM
Bill6:00:00 AM2:30:00 PM
Cathy9:00:00 AM7:30:00 PM
Donald5:00:00 AM2:00:00 PM
Edward5:00:00 AM4:00:00 PM
Frank5:00:00 AM9:00:00 AM
George5:00:00 AM4:00:00 PM
Harold12:30:00 AM8:00:00 AM
Isaac1:00:00 PM9:00:00 PM
Jim2:00:00 PM10:00:00 PM
Kimberly8:00:00 AM4:00:00 PM
Lawrence2:00:00 PM10:00:00 PM
Martha11:30:00 AM10:30:00 PM
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hey AntBlabby,

Can you separate your header row into two rows? Or just use a single value to either represent the start time or the end time?

This would make the formula much easier as you could just check if the time is before or after your starting/finishing times for each person.
 
Upvote 0
Hey AntBlabby,

Can you separate your header row into two rows? Or just use a single value to either represent the start time or the end time?

This would make the formula much easier as you could just check if the time is before or after your starting/finishing times for each person.
Yes to the second, I believe. Not so much the first.
 
Upvote 0
That should work for you - do you want a walkthrough or are you going to give it a shot?

Should be as easy as changing the times across the top and then just using "IF" formulas to add something like a "Y" or a 1 to each cell.

If you use a "Y" you can "COUNTA" or "COUNTIF" the number of times the "Y" is there.
If you use a 1 you can SUM them.
 
Upvote 0
try this: It is essently a GANTT chart:


mr excel questions 13.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1NameStart TimeEnd Time12:01am-1:00am1:01am-2:00am2:01am-3:00am3:01am-4:00am4:01am-5:00am5:01am-6:00am6:01am-7:00am7:01am-8:00am8:01am-9:00am9:01am-10:00am10:01am-11:00am
200:0001:0002:0003:0004:0005:0006:0007:0008:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:0019:0020:0021:0022:0023:00
3Joe01:0006:30012222200000000000000000
4Amy11:0019:30000000000001222222200000
5Bill06:0014:30000000122222220000000000
6Cathy09:0019:30000000000122222222200000
7Donald05:0014:00000001222222220000000000
8Edward05:0016:00000001222222222200000000
9Frank05:0008:30000001220000000000000000
10George05:0016:00000001222222222200000000
11Harold00:3008:00122222220000000000000000
12Isaac13:0021:00000000000000012222222000
13Jim14:0022:00000000000000001222222200
14Kimberly08:0016:00000000001222222200000000
15Lawrence14:0022:00000000000000001222222200
16Martha11:3022:30000000000001222222222200
Sheet3
Cell Formulas
RangeFormula
E2:AA2E2=D2+1/24
D3:AA3,AA4:AA16D3=((--(D$2>$B3))+(--((D$2+(59/(24*60)))>$B3)))*(--(D$2<=$C3))
D4:Z16D4=((--(D$2>$B4))+(--((D$2+(59/(24*60)))>$B4)))*(--(E$2<=$C4))
 
Upvote 0
in the above you can use the formula in cell D3 for conditional formatting and color format the cells where the times match.
 
Upvote 0
@AntBlabby8 , the mini workbook i posted above is done in 365. If you have earlier version 2010 and up, you may need to wrap the formula in a SUMPRODUCT function and use CNTL-SHFT-ENTER to enter the formula. (You may want to update your profile to indicate which version of excel you use so future questions can be more tailored to your version.)
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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