count rows with date

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
569
Office Version
  1. 365
Platform
  1. Windows
I have two columns, ColA with a date in it and the ColB with just the years from 2006 - 2017. I would like a formula which counts the numbers of rows in ColA that have years that match the year listed in ColB. I am currently using the formula listed below and it is not working. Please help. I know this is simple, just having a brain derailment on this one.

=COUNTIF(A:A,YEAR(B2))

Thanks in advance,

Robert
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If B2 is a number (like 2016) and not a date, here is one way:
Code:
=COUNTIFS(A:A,">=" & DATE(B2,1,1),A:A,"<=" & DATE(B2,12,31))
 
Upvote 0
If the value in B2 is really a date and not a number, just change the reference to B2 in the formula I proposed to YEAR(B2)
Code:
=COUNTIFS(A:A,">=" & DATE(YEAR(B2),1,1),A:A,"<=" & DATE(YEAR(B2),12,31))
 
Upvote 0
when I try that formula, the result I get is 0. What am I doing wrong? :mad:
 
Last edited:
Upvote 0
Tell me what these two formulas return (assuming A2 is the first cell in column A with a date in it):
Code:
=ISNUMBER(A2)
=ISNUMBER(B2)
 
Upvote 0
I get TRUE for both when I checked using that formula.
 
Upvote 0
Does this work?


Book1
ABC
101-01-20072
201-01-2008
301-01-20092008
401-01-2010
501-01-2008
Sheet1
Cell Formulas
RangeFormula
C1=SUMPRODUCT(--(YEAR(A1:A10)=B3))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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