Sub duration()
Dim lr As Long
Dim ws As ThisWorkbook
Set ws = ThisWorkbook
ls = Sheets("COBACOBA").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To ls
Cells(i, 29).Formula = Application.WorksheetFunction.NetworkDays_Intl(CDate(Cells(i, 16)), CDate(Cells(i, 28)))
Next i
End Sub
I have to find the number of working days between two dates which should exclude weekends and National Holidays. I am using function NETWORKDAYS in vba, this excludes weekends but I want to exclude Some National Holidays as well. How to use this function NETWORKDAYS(startDate, endDate, [holidays]) for National holidays. but my holidays list is on another excel file how to input data from my holiday.xlsx to my vba
Sub duration()
Dim ws As ThisWorkbook
Set ws = ThisWorkbook
Dim wk As Workbook
lr = Sheets("COBACOBA").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lr
Cells(i, 29).Formula = Application.WorksheetFunction.NetworkDays_Intl(CDate(Cells(i, 16)), CDate(Cells(i, 28)), , Workbooks("Holiday.xlsx").Worksheets("Hol").Range("A2:A56"))
Next i
End Sub