Solved

CountIFS Date Range

Posted on 2014-10-30
5
159 Views
Last Modified: 2014-11-24
Hi

Excel 2010

I have two tabs on my worksheet
Main and Stats

In the Main I have data as follows
Matter       Date
1                  01/09/2014
2                  21/09/2014
3                  03/10/2014

In the stats I have
Month                Number
01/09/2014
01/102014

for the number column, I want to count all dates that correspond to the month and year in the Month column in the Stats tab

i.e. I would get the following based on the example data

Month                Number
01/09/2014         2
01/102014           1

Any help would be appreciated
0
Comment
Question by:halifaxman
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40414261
You can use an array formula to determine this.

If your Main data is in columns A&B and your Stats "Month" is in column A and you want the number of occurrences to appear in column B, you'd insert this formula (this is in cell B2, use [Ctrl]+[Shift]+[Enter] to enter):
=SUM(IF(MONTH(Main!$B$2:$B$51)&"-"&YEAR(Main!$B$2:$B$51)=MONTH(A2)&"-"&YEAR(A2),1,0))

Then copy that formula down as far as needed.  I'm only testing through row 51; you'll want to change that value to the number of rows in your Main sheet.

Example file attached.  It also has a PivotTable that verifies the results (using Group option on the dates to show month and year).

-Glenn
EE-Q28547994.xlsx
0
 
LVL 32

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 40415462
Don't need an array formula, this can be done with COUNTIF:

Stats sheet
Col A            Col B
Date             Count
01/09/14     =COUNTIF(Main!B:B,"<="&EOMONTH(A2,0))-COUNTIF(Main!B:B,"<"&A2)

Thanks
Rob H
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40416114
^Nice.  Couldn't get much simpler.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40462291
I've requested that this question be closed as follows:

Accepted answer: 500 points for Rob Henson's comment #a40415462

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now