Converting a list of date ranges into weekly distribution array

vpandey4

New Member
Joined
Jun 7, 2022
Messages
6
Office Version
  1. 365
Hi,

I have a list of data with employees and their holiday data ranges, which I want to transform into an array with weeks (showing week ending date - Friday) to show days of absence in that week

EmployeeStartEndWeek Ending -->
03-May​
10-May​
17-May​
E01
30-Apr​
15-May​
4​
5​
3​
E02
08-May​
09-May​
0​
2​
0​
E03
10-May​
13-May​
0​
1​
1​
E04
07-May​
07-May​
0​
1​
0​

Is it possible to get it with some easy formula? I tried with a combination of nested Ifs but became too long and was wondering if I may overlooking an easy solution.
Please suggest.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Give this a try:
MrExcel_20220607.xlsx
ABCDEFG
1EmployeeStartEndWeek Ending -->5/3/20195/10/20195/17/2019
2E014/30/20195/15/2019453
3E025/8/20195/9/2019020
4E035/10/20195/13/2019011
5E045/7/20195/7/2019010
Sheet3
Cell Formulas
RangeFormula
E2:G5E2=IF(AND(WEEKNUM(E$1,16)>=WEEKNUM($B2,16),WEEKNUM(E$1,16)<=WEEKNUM($C2,16)),MIN(E$1,$C2)-MAX(E$1-4,$B2)+1,0)

...or the slightly simpler version without the IF function:
Excel Formula:
=AND(WEEKNUM(E$1,16)>=WEEKNUM($B2,16),WEEKNUM(E$1,16)<=WEEKNUM($C2,16))*(MIN(E$1,$C2)-MAX(E$1-4,$B2)+1)
 
Last edited:
Upvote 0
Give this a try:
MrExcel_20220607.xlsx
ABCDEFG
1EmployeeStartEndWeek Ending -->5/3/20195/10/20195/17/2019
2E014/30/20195/15/2019453
3E025/8/20195/9/2019020
4E035/10/20195/13/2019011
5E045/7/20195/7/2019010
Sheet3
Cell Formulas
RangeFormula
E2:G5E2=IF(AND(WEEKNUM(E$1,16)>=WEEKNUM($B2,16),WEEKNUM(E$1,16)<=WEEKNUM($C2,16)),MIN(E$1,$C2)-MAX(E$1-4,$B2)+1,0)

...or the slightly simpler version without the IF function:
Excel Formula:
=AND(WEEKNUM(E$1,16)>=WEEKNUM($B2,16),WEEKNUM(E$1,16)<=WEEKNUM($C2,16))*(MIN(E$1,$C2)-MAX(E$1-4,$B2)+1)
Hi @KRice : Thanks- It works for a data set of 01 year but since my data goes through recursively for more than a year- WEEKNUM returns TRUE condition for the next year range as well. Any idea how to control that?
 
Upvote 0
Hi @KRice : Thanks- It works for a data set of 01 year but since my data goes through recursively for more than a year- WEEKNUM returns TRUE condition for the next year range as well. Any idea how to control that?
I tried appending TEXT(cell,"yy")&WEEKNUM(xyz) to solve this... but please suggest if you have a better solution
 
Upvote 0
I think starting over might be better. And rather than trying to determine if we are in a week that matters, the formula should return a nonsense answer that can be trapped. Try this:
MrExcel_20220607.xlsx
BCDEFGHIJKLMNOP
1StartEndWeek Ending -->5/4/20185/11/20185/18/20185/3/20195/10/20195/17/201912/27/20191/3/20201/10/20205/1/20205/8/20205/15/2020
24/30/20195/15/2019000453000000
35/10/20185/16/2018023000000000
45/10/20195/13/2019000011000000
55/9/20195/13/2019000021000000
612/24/20191/8/2020000000453000
75/2/20185/17/2018354000000000
85/2/20205/11/2020000000000051
Sheet3
Cell Formulas
RangeFormula
E2:P8E2=MAX(MIN(MIN($C2,$C2+7-WEEKDAY($C2+7-6)),E$1)-MAX($B2,E$1-4)+1,0)
 
Upvote 0
Solution
I think starting over might be better. And rather than trying to determine if we are in a week that matters, the formula should return a nonsense answer that can be trapped. Try this:
MrExcel_20220607.xlsx
BCDEFGHIJKLMNOP
1StartEndWeek Ending -->5/4/20185/11/20185/18/20185/3/20195/10/20195/17/201912/27/20191/3/20201/10/20205/1/20205/8/20205/15/2020
24/30/20195/15/2019000453000000
35/10/20185/16/2018023000000000
45/10/20195/13/2019000011000000
55/9/20195/13/2019000021000000
612/24/20191/8/2020000000453000
75/2/20185/17/2018354000000000
85/2/20205/11/2020000000000051
Sheet3
Cell Formulas
RangeFormula
E2:P8E2=MAX(MIN(MIN($C2,$C2+7-WEEKDAY($C2+7-6)),E$1)-MAX($B2,E$1-4)+1,0)
Thank you!!
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,991
Members
452,541
Latest member
haasro02

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