Formula Help - Count the number of days from a specific date but exclude Sundays

easybpw

Active Member
Joined
Sep 30, 2003
Messages
437
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Good morning and thanks in advance for the help.

Is there a formula that could count the number of days in the month your in but exclude Sundays? For example, today is 8/20/2020 so the number would be 20 but if we exclude the 3 Sunday's we've had so far this month the number would be 17. Is this possible?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Here is a code that has optional InclSaturdays and InclSundays

Assuming your start date is in Cell A1 and your end date is in Cell B1, your formula would look like this

Code:
=CountWorkingDays(A1,B1,TRUE,FALSE)


VBA Code:
Option Explicit
'THIS IS NOT MY CODE, GOT THIS FROM https://www.exceltip.com/custom-functions/calculate-the-count-of-workdays-between-two-dates-using-vba-in-microsoft-excel.html
Function CountWorkingDays(StartDate As Long, EndDate As Long, Optional InclSaturdays As Boolean = True, _
    Optional InclSundays As Boolean = True)

'Declaring variables
Dim RngFind As Range
Dim i As Long

For i = StartDate To EndDate
   
    On Error Resume Next
   
    'Finding the location where the specified date exist in the Holidays sheet
    Set RngFind = Worksheets("Holidays").Columns(1).Find(i)
   
    On Error GoTo 0
   
    'Checking whether it is holiday on the given date
    If Not RngFind Is Nothing Then
        GoTo ForLast
    End If
   
    'Checking whether it is Saturday on given date
    If InclSaturdays Then
        If Weekday(i, 2) = 6 Then
            GoTo ForLast
        End If
    End If
   
    'Checking whether it is Sunday on given date
    If InclSundays Then
        If Weekday(i, 2) = 7 Then
            GoTo ForLast
        End If
    End If
   
    CountWorkingDays = CountWorkingDays + 1
   
ForLast:

Next

End Function
 
Upvote 0
How about
=NETWORKDAYS.INTL(EOMONTH(TODAY(),-1)+1,TODAY(),11)
 
Upvote 0
Here is a formula option.

Book1
AB
1Start DateEnd Dare
28/1/20208/20/2020
3
417
Sheet2
Cell Formulas
RangeFormula
B4B4=NETWORKDAYS.INTL(A2,B2,"1000000")
 
Upvote 0
Thanks everyone! Great responses and great website!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Check Excel's help for the function.
Either of the following are correct.


T202008c.xlsm
ABC
1StartEnd
201-08-2020-08-2017
301-08-2020-08-2017
2c
Cell Formulas
RangeFormula
C2C2=NETWORKDAYS.INTL(A2,B2,"0000001")
C3C3=NETWORKDAYS.INTL(A3,B3,11)
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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