I have this code that calculates the number of working days for the month. It then shows the result on a message box. This part of the code is working perfectly.
I'm trying to add a second part (a line on the message box that also shows the number of working days thus far).
I have this part of the code set up. But it does not calculate the number of working days.
Could someone please take a look at this and fix the code?
Thank you,
Sub WorkingDays()
Dim vMo As Variant
Dim t As Date
Dim nWork As Long
Dim Today As Date
Dim EoMonth As Double
Dim NetworkDays As Double
vMo = InputBox("Enter Month (1-12); January = 1, February = 2", "Workday Calculator")
If Not IsNumeric(vMo) Then Exit Sub
t = DateSerial(Year(Date), vMo, 1)
r = nWork - NetworkDays '< ----- This line should calculate the number of working days thus far (from beginning of month to present). It does not do that yet.
With WorksheetFunction
nWork = .NetworkDays(t, .EoMonth(t, 0))
End With
MsgBox "The month of: " & Format(t, "mmmm yyyy") & " has " & nWork & " working days in it." & _
vbCrLf & vbCrLf & "Including today, " & r & " days have been worked.", , "Calculator"
End Sub
Bookmarks