Counting Date Excluded Weekend

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..

how to make formula to get date excluded weekend/holidays
<style type="text/css">
table.tableizer-table {
font-size: 12px;
border: 1px solid #CCC ;
font-family: Arial, Helvetica, sans-serif;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #CCC ;
}
.tableizer-table th {
background-color: #104E8B ;
color: #FFF ;
font-weight: bold;
}
</style>
Start dateCount DateExpected result
22/04/20192221/05/2019

<tbody>
</tbody>


thanks in advance..

sst.
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You can use this but you will need to have a list of holiday dates as the 3rd variable in the formula

Row\Col
A​
B​
C​
D​
E​
1​
Start date
Count Date
Expected result
2​
22/04/2019​
=NETWORKDAYS(A2,C2,E4)​
21/05/2019​
3​
4​
annual day
15/05/2019​
5​
6​
 
Last edited:
Upvote 0
hi M...sorry i mean in count date (col.B) is data given not use formula
 
Upvote 0
Lightly tested but give this UDF a try. Change the holidays list to suit. Note I'm using US date system.
Excel Workbook
ABCDE
1Start DateCount DateResultHolidays
24/22/2019225/22/20194/29/2019
31/1/2019
Sheet1


Code:
Function EndDate(StartDate As Date, NetDays As Long, HolDays As Range) As Date
Dim ct As Long, NxtDate As Date
NxtDate = StartDate
Do
    For i = 1 To HolDays.Count
        If NxtDate = HolDays(i) Then GoTo Nx
    Next i
    If Weekday(NxtDate) <> vbSunday And Weekday(NxtDate) <> vbSaturday Then
        ct = ct + 1
        If ct = NetDays Then Exit Do
    End If
Nx:    NxtDate = NxtDate + 1
Loop
EndDate = NxtDate
End Function
 
Upvote 0
hi Joe....

thanks you s0 much
You are welcome - thanks for the reply. Here's a version of the UDF that eliminates looping through the Holiday dates. Should be a bit faster in case you employ the UDF in many cells throughout a worksheet.
Code:
Function EndDate(StartDate As Date, NetDays As Long, HolDays As Range) As Date
Dim ct As Long, NxtDate As Date, IsHoliday As Variant
NxtDate = StartDate
Do
    IsHoliday = Application.Match(CLng(NxtDate), HolDays, 0)
    If Not IsError(IsHoliday) Then GoTo Nx
    If Weekday(NxtDate) <> vbSunday And Weekday(NxtDate) <> vbSaturday Then
        ct = ct + 1
        If ct = NetDays Then Exit Do
    End If
Nx:    NxtDate = NxtDate + 1
Loop
EndDate = NxtDate
End Function
 
Upvote 0

Forum statistics

Threads
1,214,574
Messages
6,120,327
Members
448,956
Latest member
Adamsxl

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