Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

performing a function on a variable cell

Status
Not open for further replies.

itfellow

MIS
Jan 6, 2004
130
0
0
US
Hi all,

I've got a spreadsheet with one column that is full of dates, and I want to add up the number of dates that fall within each year. So, if, for example, cells A1:A10 each have dates, I would like to know if it is possible to have a formula in cell A11 which counts all of the dates that fall in year 2008 by using:

=countif(a1:a10, year(?)=2008)

where ? is a variable which refers to the current cell being examined. Is there a way to do this in Excel?
 




Hi,
[tt]
=sumproduct(--(a1:a10>=DateValue("2008/01/01"))*(a1:a10<=DateValue("2008/12/31")))
[/tt]


Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
Not sure of a direct solution to your problem, but an alternative workaround would be to insert a column next to your date column. Insert the year value of the preceding column using
Code:
=year(colA)
From there, you could then do a countif on the inserted column since you would then be looking only at the year as you designated in your post.

------------------------------------------------------------------------------------------------------------------------
"As for the bureacratic, politically-correct, mollycoddling, asinine, Romper Room antics of...clients and management, just read up on Dilbert. It's not funny - it's a training manual."
- Mike
 



also
[tt]
=SUMPRODUCT(--(YEAR(A1:A10)=2008))
[/tt]

Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
Thanks, the SUMPRODUCT formula did the trick perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top