Counting The Number of People on Leave on a Given Date

JosephGiri

New Member
Joined
Jan 15, 2014
Messages
3
Hi everyone,

I have a leave application data entry table that looks like this,
SheetName: Data
A: Name
B: Start Date
C: End Date​

I have a separate sheet that has the following structure,
SheetName: Counter
A: Date (from 01 Jan to 31 Dec)
B: No of People on Leave​

I need to create a non-VBA solution to populate column B in Counter.

A sample set of data is shown below,
SheetName:Data
ABC
1NameStart DateReturn Date
2P11-Jan6-Jan
3P21-Jan7-Jan
4P31-Jan12-Jan
5P44-Jan5-Jan
6P56-Jan10-Jan
7P610-Jan12-Jan
8P713-Jan18-Jan
9P819-Jan21-Jan
10P926-Jan9-Feb
11P1028-Jan1-Feb
12P1129-Jan2-Feb
13P1230-Jan6-Feb
14P1330-Jan1-Feb
15P1430-Jan3-Feb
16P1530-Jan1-Feb
17P1631-Jan5-Feb
18P1728-Feb9-Mar
19P1818-Apr23-Apr

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

My expected result (only showing for Jan) is,
ShhetName: Counter
AB
1DateNumber of Ppl on Leave
201 Jan3
302 Jan3
403 Jan3
504 Jan4
605 Jan3
706 Jan3
807 Jan2
908 Jan2
1009 Jan2
1110 Jan2
1211 Jan2
1312 Jan0
1413 Jan1
1514 Jan1
1615 Jan1
1716 Jan1
1817 Jan1
1918 Jan0
2019 Jan1
2120 Jan1
2221 Jan0
2322 Jan0
2423 Jan0
2524 Jan0
2625 Jan0
2726 Jan1
2827 Jan1
2928 Jan2
3029 Jan3
3130 Jan7
3231 Jan8

<colgroup><col><col><col></colgroup><tbody>
</tbody>


I achieved this by "brute force", as follows,
  • creating a 31 column range with the individual dates as the column headers
  • use a formula to check if the date in the header is in between Start Date and End Date
  • count the number of "TRUE" cases found for each date
  • Transpose into a new sheet for display purposes

There must be a more elegant solution as the above approach takes time to recalculate after each set of entries.

Any help would be appreciated.

Thank you.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
For some weird issue, the formula got truncated.. here is the full one

=Sumproduct(--(A2>=Data!B2:B19),--(A2< <data!b2:b19))< html=""></data!b2:b19))<>Data!B2:B19))
 
Upvote 0
For some weird issue, the formula got truncated.. here is the full one

=Sumproduct(--(A2>=Data!B2:B19),--(A2< <data!b2:b19))< html=""></data!b2:b19))<>Data!B2:B19))

Works brilliantly. Thank you so very much.

What is the significance of the "--" in the formula?
 
Upvote 0
a double negative (--) converts True to 1 and False to 0

So --(True) becomes 1 and --(False) becomes 0
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
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