Counting weekdays

Sven62

Active Member
Joined
Feb 21, 2012
Messages
485
Please tell me why this =SUMPRODUCT(WEEKDAY($B2:$B2048,1)=1)) works fine for Sunday and =2, =3 etc. work for Tuesday thru Friday. There are 148 rows with data to count and they all get counted correctly. The remaining rows are blank.

Except that...

=SUMPRODUCT(WEEKDAY($B2:$B2048,1)=7)) on Saturday returns "1912". It is apparently counting blank cells for some reason. Why does this happen only for Saturday?

I am using =SUMPRODUCT(--($B2:$B2048<>""),--(WEEKDAY($B2:$B2048,1)=7)) to correct for it. But why do I need to do that?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Not so sure if either of your first two formula is working. The formulas are giving TRUE's and FALSE's.
You need to use "--" to turn them into ONE's and ZERO's as you are doing in your last formula.
So doesn't this one work for you?
=SUMPRODUCT(--(WEEKDAY($B2:$B2048,1)=7))
 
Upvote 0
OOPS you're right... they do have -- and they work but Saturday does not. Saturday returns 1912. It is counting blank cells.
 
Last edited:
Upvote 0
You're right, I wasn't aware of that. Tried WEEKDAY function on blank cells and it returns 7.
I might be wrong here but the day zero in Excel, 01.01.1900, was probably a saturday. The weekday function
probably see empty cells as zero and coercing the blank cells into a number and then interpreting it as a date
 
Last edited:
Upvote 0
You're right, I wasn't aware of that. Tried WEEKDAY function on blank cells and it returns 7.
I might be wrong here but the day zero in Excel, 01.01.1900, was probably a saturday. The weekday function
probably see empty cells as zero and coercing the blank cells into a number and then interpreting it as a date

I bet you are right. Freakin' genius.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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