Hi,
* Basically, the formula counts number of Saturdays starting from Day 1 of the month to the specified date.
* Weekday function returns 7 for Saturday so we use it for checking if a day is Saturday. So if your week beginning is Sunday then it will be =1 in place of =7.
* EOMONTH(A1,-1) returns last date of previous month which we use as starting point.
* ROW($A$1:INDEX(A:A,A1-EOMONTH(A1,-1))) returns an array of number of days upto out given date in cell A1 like {1,2,3,4,5,6,7}
* These are added to give all dates starting from Day 1 of the month to date specified in the month, inclusive of both.
* Then WEEKDAY function simply count number of Saturdays and adds 1 to the final total [This is flawed logic, see below I have corrected it]. This conditional calculation is done by SUMPRODUCT. '--' means double unary which converts boolean (TRUE / FALSE) result to number (1 / 0).
So I think this formula will fail if the first day of month is a Saturday. So it needs small adjustment to logic.
=SUMPRODUCT(--(WEEKDAY(EOMONTH(A1,-1)+ROW($A$1:INDEX(A:A,A1-EOMONTH(A1,-1))))=7))+(WEEKDAY(EOMONTH(A1,-1)+1)<>7)*1
I have replaced 1 with condition check for the first day of month being Saturday.