Convert date range into sum of work days per week

Hamitoco

New Member
Joined
Oct 13, 2019
Messages
5
Hi,

If I have a date range in excel, lets say for example 8th Feb 2021 - 25th Feb 2021 am I able to create a formula that works out what weeks of the year that date range falls in and how many workdays (excluding weekends) per week.
Heres how I'm hoping it will work:
8th Feb-25th Feb falls in weeks 7-9 in the year (using excels weeknum funtion) for this particular date range there is a total of 5 workdays in week 7, 5 workdays in week 8 and 4 workdays in week 9.

Thanks.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi,

You didn't specify how you want the results presented, maybe:

Book3.xlsx
ABCD
1FromToWeek NumbersWorkdays
22/8/20212/25/20217 to 914
Sheet747
Cell Formulas
RangeFormula
C2C2=WEEKNUM(A2,1)&" to "&WEEKNUM(B2,1)
D2D2=NETWORKDAYS(A2,B2)


For the Week numbers, I'm using Begins with Sunday, change it to what you want.
 
Upvote 0
Hi,

Thanks for your reply. A bit of context for what I'm trying to achieve here. I am working with a labour forecast file where I would like to know how many days of annual leave is booked on any given week of the year. the examples below is kind of how i would like it to work or something similar if possible.
1612846384910.png


1612846564158.png


Thanks
 
Upvote 0
Try this
VBA Code:
Public Function CountDaysOfWeek(ByVal rngData As Range, Week As Long) As Long
Dim i As Long, j As Long, temp As Long, arrData As Variant
arrData = rngData.Value2
For i = 1 To UBound(arrData, 1)
    For j = arrData(i, 1) To arrData(i, 2)
        If Application.WeekNum(j) = Week Then
            If VBA.Weekday(j, vbMonday) < 6 Then temp = temp + 1
        End If
    Next j
Next i
CountDaysOfWeek = temp
End Function

Use:

=CountDaysOfWeek($B$2:$C$4,G2)
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

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