Verovatno može i preko formula, ali bi bilo predugačko. Meni lakše napraviti custom vba function.
Ovde je naravno pretpostavka da startDate < endDate i da su oba datuma u istoj godini, u suprotom je 0.
Ne pokriva ni praznike...ali moglo bi da se reši.
Code:
Public Function GetWorkdays(ByVal startDate As Date, ByVal endDate As Date, monthNum As Integer) As Double
On Error GoTo GetWorkdaysOnError
Dim startMonth, endMonth As Integer
Dim sof, eof As Date
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
GetWorkdays = 0
startMonth = month(startDate)
endMonth = month(endDate)
If ((startMonth > monthNum And endMonth < monthNum) Or (Year(startDate) <> Year(endDate)) Or (startDate > endDate)) Then
Exit Function
ElseIf (startMonth < monthNum And endMonth > monthNum) Then
sof = DateSerial(Year(startDate), monthNum, 1)
eof = wf.EoMonth(sof, 0)
ElseIf (startMonth = monthNum And endMonth = monthNum) Then
sof = startDate
eof = endDate
ElseIf (startMonth = monthNum) Then
sof = startDate
eof = wf.EoMonth(sof, 0)
ElseIf (endMonth = monthNum) Then
sof = DateSerial(Year(endDate), monthNum, 1)
eof = endDate
End If
GetWorkdays = wf.NetworkDays(sof, eof)
GetWorkdaysOnError:
Set wf = Nothing
End Function