Count Agents Scheduled by half hour

polarnavs

New Member
Joined
Feb 22, 2014
Messages
46
I have agents with varying start and end times and I'm trying find a macro or formula to return the number of agents scheduled for the times listed.
I have included a sample set of data and the values that I know the formula or macro should return.
Any help would make a HUGE difference to me.
Thanks


EmployeeStartEnd
Ellis, Christopher4 A12 P
Emond, Meloney4 A12 P
Frederick, Alexander4 A11 A
Gregory, Ricky4 A12 P
Lavoie, Eric4 A12 P
Poulin, Patricia5 A11 A
Andrews, Dale6 A2 P
Begin, Gary6 A2 P
HourAgents Count
12 A0
1 A0
2 A0
3 A0
4 A5
5 A6
6 A8
7 A8
8 A8
9 A8
10 A8
11 A8
12 P6
1 P6
2 P6
3 P0
4 P0
5 P0
6 P0
7 P0
8 P0
9 P0
10 P0
11 P0

<TBODY>
</TBODY><COLGROUP><COL><COL><COL></COLGROUP>
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
=COUNTIFS($B$2:$B$9,"<="&A10,$C$2:$C$9,">="&A10)

Should work assuming you adjust your ranges accordingly (per the above your source data is in A2:A9 and the beginning of your table is at A10). You can copy it down your whole range.

Cheers, :)
 
Upvote 0
This is working great but won't wrap the agents into the next day if their shift overlaps (i.e. 10p-3a). Any thoughts?
 
Upvote 0
There's probably a better way to do this but this should work.

Next to your end time column (in column D) you can add a helper column with the following expression copied down the range.

=IF(B2>C2,C2+1,C2)


Then use the following expression to count the staff people by 1/2 hour

=COUNTIFS($B$2:$B$9,"<="&A10,$D$2:$D$9,">="&A10)+COUNTIFS($B$2:$B$9,"<="&A10+1,$D$2:$D$9,">="&A10+1)

Cheers, :)
 
Upvote 0
Oops, the above doesn't work out. Try:

=COUNTIFS($B$2:$B$9,"<="&A10,$D$2:$D$9,">="&A10)+COUNTIFS($D$2:$D$9,">="&A10+1)

Cheers, :)
 
Upvote 0
I'm not sure how the text values will affect your counts so can you show me some sample data with those text values?
 
Upvote 0
MondayTuesdayWednesdayThursdayFridaySaturdaySunday
StartEndStartEndStartEndStartEndStartEndStartEndStartEnd
OFFOFFOFFOFFOFFOFF11 P7 A11 P7 A11 P7 AOFFOFF
OFFOFF9 A4 P9 A4 P12 P4 P9 A4 P9 A2 POFFOFF
11 P7 A11 P7 AOFFOFFOFFOFF11 P7 A11 P7 AOFFOFF
9 A3 P9 A3 P9 A3 POFFOFFOFFOFFOFFOFF10 A3 P
11 A4 P11 A3 P11 A3 P11 A3 POFFOFFOFFOFFOFFOFF
OFFOFF11 P7 A11 P7 A11 P7 A11 P7 A11 P7 AOFFOFF
6 A2 P6 A2 P6 A2 P6 A2 P6 A2 POFFOFFOFFOFF

<TBODY>
</TBODY><COLGROUP><COL span=14></COLGROUP>
 
Upvote 0
I don't believe that text values above should affect the counts. Are you sure it does? If so, how exactly?
 
Upvote 0

Forum statistics

Threads
1,215,666
Messages
6,126,106
Members
449,292
Latest member
Mario BR

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