Count date occurrence, mine code doesn't work

most

Board Regular
Joined
Feb 22, 2011
Messages
107
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. Mobile
Hello!
Can anyone help me explain what's wrong here and how to solve it?

Code:
{=SUM(IF(MONTH(named_range)=C3,1))}

jjsaip.jpg


My expectation is that the code should count occurrence of a specific month of the dates in the green field(named_range).
Month 2-12 works fine, but month 1 return the number of rows in the named range minus occurrence of the other months, in this case 6.

If there is a better way to solve it, i'm all ears.

regards Marcus
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try
=SUM(IF((MONTH(DRng)=C3)*(DRng<>""),1))
Your formula is adding the blank cells to January
 
Upvote 0
Here is another formula (normally entered) that you can consider...

=SUMPRODUCT(--(MONTH(named_range)=C3),--(named_range<>""))
 
Last edited:
Upvote 0
...and of course, both of them works perfectly. Thanks! Case closed.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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