Hi Root,
Thanks a lot. I have tested on a few dates and it works. However, to apply it in VBA, a bit tedious
In my real case, I am using Date/Time picker in Userform Multipage and thus need to use VBA which is more complicated.
MOD(A1,1) in VBA does not available.
I need to use select case due to Holidays is different depending on case.
Then, MOD(A1,1) will change to A1/1 - Int(A1/1) to get the decimal points value.
Sub Countdays()
Dim wsH As Worksheet
Dim DateValue1 As Double, DateValue2 As Double
Set wsH = Sheets("Holidays")
With Application.WorksheetFunction
DateValue1 = 0
DateValue2 = 0
DateValue1 = (CDate(Format(DTPickerReceive, "dd-mmm-yyyy hh:mm")) / 1) - Int(CDate(Format(DTPickerReceive, "dd-mmm-yyyy hh:mm")) / 1)
DateValue2 = (CDate(Format(DTPickerComplete, "dd-mmm-yyyy hh:mm")) / 1) - Int(CDate(Format(DTPickerComplete, "dd-mmm-yyyy hh:mm")) / 1)
Select Case Me.ComboBoxRegion
Case "XYZ_1"
Me.TextBox1.Value = NetworkDays_Intl(DTPickerReceive, DTPickerComplete, 1, wsH.Range("B3:B50")) - 1 - DateValue1 + DateValue2
Case "XYZ_2"
Me.TextBox1.Value = .NetworkDays_Intl(DTPickerReceive, DTPickerComplete, 1, wsH.Range("D3:D50")) - 1 - DateValue1 + DateValue2
Case "XYZ_3"
Me.TextBox1.Value = .NetworkDays_Intl(DTPickerReceive, DTPickerComplete, 1, wsH.Range("F3:F50")) - 1 - DateValue1 + DateValue2
Case "XYZ_4"
Me.TextBox1.Value = .NetworkDays_Intl(DTPickerReceive, DTPickerComplete, 1, wsH.Range("H3:H50")) - 1 - DateValue1 + DateValue2
'
'
'
' and other cases
End Select
End With
End Sub
Bookmarks