killitmore > 23-11-17, 12:02 PM
Public Function workday_intl(dt_start As Date, dt_end As Date, int_weekend As Integer, _
Optional str_country As String = "VN", _
Optional str_holiday_table As String = "TBL_HOLIDAY_LU", _
Optional str_holiday_field As String = "HOLIDAY_DATE") As Double
Dim excel_obj As New Excel.Application
Dim rst_holiday As DAO.Recordset
Set rst_holiday = CurrentDb.OpenRecordset("SELECT " & str_holiday_field & " FROM " & str_holiday_table _
& " WHERE COUNTRY = '" & str_country & "'")
workday_intl = excel_obj.WorksheetFunction.NetworkDays_Intl(dt_start, dt_end, int_weekend, _
excel_obj.Range("A1:A" & rst_holiday.RecordCount).CopyFromRecordset(rst_holiday))
Set excel_obj = Nothing
End Function