Networkdays not including the weekends

Jefferson2512

Board Regular
Joined
Sep 16, 2019
Messages
53
I am using a Userform and a vba code in Networkdays .. can someone help me with my problem about networkdays that won't include the weekends/holidays ?


Code:
  Dim dblNetworkDays As Long
    Dim dblNetworkDays1 As Long


        dblNetworkDays = -(WorksheetFunction.NetworkDays(txt1, txt2))
        dblNetworkDays1 = (100 - (WorksheetFunction.NetworkDays(txt1, txt2) - 1) * 5)


            If txt1.Value = "" Or txt2.Value = "" Then
                lbl1.Caption = ""
                ElseIf txt1.Value = txt2.Value Or txt1.Value > txt2.Value Then
                lbl1.Caption = "-"
                ElseIf dblNetworkDays = -(WorksheetFunction.NetworkDays(txt1, txt2)) Then
                lbl1.Caption = dblNetworkDays
                Me.lbl1.Caption = Format(lbl1.Caption, "[Blue]###,##(0);[Red](###,##0)")
            End If
    
            If txt1.Value = "" Or txt2.Value = "" Then
                lblTotal.Caption = ""
                ElseIf txt1.Value = txt2.Value Or txt1.Value > txt2.Value Then
                lblTotal.Caption = "100.00"
                ElseIf dblNetworkDays1 = (100 - (WorksheetFunction.NetworkDays(txt1, txt2) - 1) * 5) Then
                lblTotal.Caption = dblNetworkDays1
    
            If lblTotal.Caption <= 0 Then
                lblTotal.Caption = "0.00"
            End If
                Me.lblTotal.Caption = Format(Me.lblTotal.Caption, "##0.00")
            End If
                enlbl.Caption = lblTotal.Caption
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,213,484
Messages
6,113,920
Members
448,533
Latest member
thietbibeboiwasaco

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