Макросом
Option Explicit
Private Sub WorkDays()
Dim FirstDate As Date
Dim EndDate As Date
Dim iFirstRow As Long
Dim iFirstCol As Long
Dim iEndRow As Long
Dim iEndCol As Long
FirstDate = Range("C1")
EndDate = Range("C2")
iFirstRow = Columns("A").Find(Day(FirstDate), , xlFormulas, xlWhole).Row
iEndRow = Columns("A").Find(Day(EndDate), , xlFormulas, xlWhole).Row
iFirstCol = Rows(5).Find(DateSerial(Year(FirstDate), Month(FirstDate), 1), , xlFormulas, xlWhole).Column
iEndCol = Rows(5).Find(DateSerial(Year(EndDate), Month(EndDate), 1), , xlFormulas, xlWhole).Column
Range("B3").ClearContents
If iFirstCol = iEndCol Then
Range("B3") = WorksheetFunction.CountIf(Range(Cells(iFirstRow, iFirstCol), Cells(iEndRow, iEndCol)), "рабочий")
Else
If iFirstCol = iEndCol - 1 Then
Range("B3") = WorksheetFunction.CountIf(Range(Cells(iFirstRow, iFirstCol), Cells(39, iFirstCol)), "рабочий") _
+ WorksheetFunction.CountIf(Range(Cells(9, iEndCol), Cells(iEndRow, iEndCol)), "рабочий")
Else
Range("B3") = WorksheetFunction.CountIf(Range(Cells(iFirstRow, iFirstCol), Cells(39, iFirstCol)), "рабочий") _
+ WorksheetFunction.Sum(Range(Cells(7, iFirstCol + 1), Cells(7, iEndCol - 1))) _
+ WorksheetFunction.CountIf(Range(Cells(9, iEndCol), Cells(iEndRow, iEndCol)), "рабочий")
End If
End If
End Sub