Count days of a range within a weeknum

HeiNeken

New Member
Joined
Nov 16, 2015
Messages
12
Hi all,

I have a bit trouble wrapping my head around this little roadblock I came across. I have a cell with a start date and another cell with an end date let's call them a1 and a2. I want to count how many of the days between the 2 dates are the same week number.

example:

a1= 4/11/18
a2= 4/17/18
the total workdays between the 2 dates are 5. 3 of them are weeknum 15 and 2 are weeknum 16

I am looking for a way to count the number of days for each weeknum.

thank you in advance
Dan
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
b4UcgJ6.jpg
[/URL][/IMG]
here is an image of my spreadsheet that I am working on. I hope that explains better what I am trying to do.

thank you for any help
 
Last edited:
Upvote 0
Row\Col
A​
B​
1​
4/11/2018​
2​
4/17/2018​
3​
4​
15​
2​
5​
15​
6​
16​
3​
7​
16​
8​
16​

In A4 control+shift+enter, not just enter, and copy down:

=IFERROR(SMALL(IF(ISNA(MATCH(WEEKDAY(ROW(INDIRECT($A$1&":"&$A$2))),{6,7},0)),WEEKNUM(ROW(INDIRECT($A$1&":"&$A$2))),""),ROWS($A$4:A4)),"")

In B4 just enter and copy down:

=IF(COUNTIFS($A$4:A4,A4)=1,COUNTIFS($A$4:$A$8,$A4),"")

Hope this is of any use for your great image.
 
Upvote 0
@Aladin,
If data are like below, what formula is necessary
In A2 is start date, in B2 End Date, in D1 is (week)15, in E1 is (week)15 and so on...
In D2:G2 need formula. Same problem like before but data are diferent location. Thank you.
15
16
17
18
11.04.2018
.....17.04.2018.....
3
2

<tbody>
</tbody>
 
Last edited:
Upvote 0
@Aladin,
If data are like below, what formula is necessary
In A2 is start date, in B2 End Date, in D1 is (week)15, in E1 is (week)15 and so on...
In D2:G2 need formula. Same problem like before but data are diferent location. Thank you.
15
16
17
18
11.04.2018
.....17.04.2018.....
3
2

<tbody>
</tbody>

Is D1:G1 given? If so:

In D1 control+shift+enter, not just enter, and copy across:

=SUM(IF(ISNUMBER(MATCH(IF(ISNA(MATCH(WEEKDAY(ROW(INDIRECT($A$2&":"&$B$2))),{6,7},0)),WEEKNUM(ROW(INDIRECT($A$2&":"&$B$2)))),D$1,0)),1))
 
Upvote 0
Is D1:G1 given? If so:

In D1 control+shift+enter, not just enter, and copy across:

=SUM(IF(ISNUMBER(MATCH(IF(ISNA(MATCH(WEEKDAY(ROW(INDIRECT($A$2&":"&$B$2))),{6,7},0)),WEEKNUM(ROW(INDIRECT($A$2&":"&$B$2)))),D$1,0)),1))


First off thank you both very much for your help. this formula did the trick for the most part ;). it sems that the week with the days Thu & Fri is short 1 and the next week with mon, tue, wed has 4 as instead to 3. (See the picture) I was wondering, how could I filter out Saturdays and Sundays.

rT0ylYv.jpg
[/URL][/IMG]


thank you
Dan
 
Upvote 0
Hi,

so after playing with the formula, I was able to figure out how to adjust for Sunday week start. Now it works great.

again thank you all very much for helping in this matter.

have a great Day
Dan
 
Upvote 0
Hi,

so after playing with the formula, I was able to figure out how to adjust for Sunday week start. Now it works great.

again thank you all very much for helping in this matter.

have a great Day
Dan

You are welcome. Thanks for the update.
 
Upvote 0
Is D1:G1 given? If so:

In D1 control+shift+enter, not just enter, and copy across:

=SUM(IF(ISNUMBER(MATCH(IF(ISNA(MATCH(WEEKDAY(ROW(INDIRECT($A$2&":"&$B$2))),{6,7},0)),WEEKNUM(ROW(INDIRECT($A$2&":"&$B$2)))),D$1,0)),1))

As always, the best. Thank you Aladin.
 
Upvote 0
Hi gents,

Well, and I am back with another question. I came across another problem I hope you could help me with. I tried to adjust the formula you gave me but it got me nowhere. What happened is, that the last weeks week number of April is the same week number as for the first week of May. Well, that messes with my monthly total. It would show me the total of the week in both months. the reason why it shows zero currently at the last week of April is cause I added a formula to hide the week with the fewer days so the yearly total wouldn't be messed up.

Could you maybe adjust the formula so that it would split the week so, that one part is shown in April and the rest in May? I made a picture to better explain what I mean.

en2cCTu.jpg
[/URL][/IMG]

Thank you all in advance
Dan
 
Upvote 0

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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