Those numbers were determined by the question you asked. For example, you know there will always be at least 24 workdays in a month with Sundays off. The 25 was just 24+1 since it helped with some of the followon formulae. 28 is the number of days in a month with no partial weeks (i.e. 4 weeks). Anyway, forget about the one above...
I thought I had posted this, but apparently I didn't hit the 'reply' button. This formula should meet your needs for Sunday off.
=DAY(EOMONTH(A1,0))-DAY(A1)+1-INT((DAY(EOMONTH(A1,0))-DAY(A1)+1)/7)-IF(WEEKDAY(A1,2)-WEEKDAY(EOMONTH(A1,0))<=0,0,1)
The first part (DAY(EOMONTH(A1,0))-DAY(A1)+1) just calculates the number of days remaining in that month.
The next part (-INT((DAY(EOMONTH(A1,0))-DAY(A1)+1)/7)) removes the number of full weeks (since every full week has one Sunday).
The final part (-IF(WEEKDAY(A1,2)-WEEKDAY(EOMONTH(A1,0))<=0,0,1)) subtracts the special case where the remaining days (i.e. a partial week) span across a Sunday. It basically says that if your start day is 'later in the week' than the end of the month, then you must have spanned across a Sunday. There is some trickery there. We know we need to either subtract 1 or nothing.
This formula is 'tuned' to having Sundays off, so if you change the day, or want to add multiple days off, then this needs to be modified and, in some cases, becomes trickier. If you are going to add multiple days, then a UDF using VBA may be the easier route. Or, you could use the first two parts of my formula as a starting point, and then create a table to see how many extra days you need to subtract. It may help to create a table with one column being the weekday of your start day, another column being the weekday of the end of the month, and a final column with the number of days you need to subtract. That last one will need to be calculated by you manually, but then you may see a pattern in that table and you can then create a nice formula to handle it.
Bookmarks