Counting Date Excluded Weekend

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
1,509
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:

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
18,193
Office Version
2013
Platform
Windows
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:

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,666
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/2019224/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
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,666
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
 

Forum statistics

Threads
1,082,151
Messages
5,363,430
Members
400,736
Latest member
Aida

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top