countif with date ranges of indeterminate length

kualjo

Board Regular
Joined
Aug 15, 2006
Messages
110
I am having trouble writing a COUNTIF formula that will tell me how many times a particular month appears in a list of dates. January may appear 10 times, February may appear 43 times, March 102 times, etc. Instead of manually selecting the range for each month and using the count feature on the status bar, I need a formula that will count for me. I tried:
COUNTIF(B:B,month(1))
COUNTIF(B:B,month=1)
as well as several other lame attempts, but kept getting a result of zero or an error. What am I missing here?
 
To account for blanks either:

Add an ISNUMBER test

=SUMPRODUCT(--(ISNUMBER($B$2:$B$1000)),--(MONTH($B$2:$B$1000)=1),--(YEAR($B$2:$B$1000)=2009))

or use a TEXT coercion

=SUMPRODUCT(--(TEXT($B$2:$B$1000,"MMYY")="0109"))
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

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