PC Review


Reply
Thread Tools Rate Thread

Counting Cells with Multiple Range Criteria (Excel 2003)

 
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2009
I'm trying to count the number of rows that matches multiple criteria in
multiple ranges. As an example, I want to count the number of rows where
both Column A and Column B have a date between 01-01-05 and 12-31-05. Where:

Column A Column B
01-02-05 12-20-05
01-06-05 02-20-06
05-06-09 03-07-05
01-02-06 01-09-06

So, in this instance, I want it to count only row 1 because both columns
match the criteria.

I've tried a couple of different Countif statements, but I can never get it
to count using the multiple criteria and ranges. Please assist.

Things I've tried:
=Countif(and(A:A,B:B), ">"&C1))+countif(and(A:A,B:B), "<"&D1) - - where C1
is equal to 01-01-05 and D1 is 12-31-05

 
Reply With Quote
 
 
 
 
Luke M
Guest
Posts: n/a
 
      30th Nov 2009
=SUMPRODUCT(--(A2:A100>C1),--(A2:A100<D1),--(B2:B100>C1),--(B2:B100<D1))

Note that unless you are using XL 2007, you can't callout the entire column
within SUMPRODUCT.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Jennifer" wrote:

> I'm trying to count the number of rows that matches multiple criteria in
> multiple ranges. As an example, I want to count the number of rows where
> both Column A and Column B have a date between 01-01-05 and 12-31-05. Where:
>
> Column A Column B
> 01-02-05 12-20-05
> 01-06-05 02-20-06
> 05-06-09 03-07-05
> 01-02-06 01-09-06
>
> So, in this instance, I want it to count only row 1 because both columns
> match the criteria.
>
> I've tried a couple of different Countif statements, but I can never get it
> to count using the multiple criteria and ranges. Please assist.
>
> Things I've tried:
> =Countif(and(A:A,B:B), ">"&C1))+countif(and(A:A,B:B), "<"&D1) - - where C1
> is equal to 01-01-05 and D1 is 12-31-05
>

 
Reply With Quote
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2009
Luke - this is returning an error when I enter it in exactly like you have
it. When I change the "--" to "-", I get a returned value of 1, so it's
still not pulling it correctly.

"Luke M" wrote:

> =SUMPRODUCT(--(A2:A100>C1),--(A2:A100<D1),--(B2:B100>C1),--(B2:B100<D1))
>
> Note that unless you are using XL 2007, you can't callout the entire column
> within SUMPRODUCT.
> --
> Best Regards,
>
> Luke M
> *Remember to click "yes" if this post helped you!*
>
>
> "Jennifer" wrote:
>
> > I'm trying to count the number of rows that matches multiple criteria in
> > multiple ranges. As an example, I want to count the number of rows where
> > both Column A and Column B have a date between 01-01-05 and 12-31-05. Where:
> >
> > Column A Column B
> > 01-02-05 12-20-05
> > 01-06-05 02-20-06
> > 05-06-09 03-07-05
> > 01-02-06 01-09-06
> >
> > So, in this instance, I want it to count only row 1 because both columns
> > match the criteria.
> >
> > I've tried a couple of different Countif statements, but I can never get it
> > to count using the multiple criteria and ranges. Please assist.
> >
> > Things I've tried:
> > =Countif(and(A:A,B:B), ">"&C1))+countif(and(A:A,B:B), "<"&D1) - - where C1
> > is equal to 01-01-05 and D1 is 12-31-05
> >

 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      30th Nov 2009
> .. I want to count the number of rows where both Column A
> and Column B have a date between 01-01-05 and 12-31-05


An alternative to try, presuming data in cols A and B are all real dates:
=SUMPRODUCT((TEXT(A1:A4,"yyyy")="2005")*(TEXT(B1:B4,"yyyy")="2005"))
Adapt the ranges to suit the actual extents. Any joy? hit the YES below
--
Max
Singapore
xde
---
 
Reply With Quote
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2009
That will only work for that particular scenario...I also need it to work for
date ranges between 02-01-05 and 01-31-06, so I can't limit it to just the
year.

"Max" wrote:

> > .. I want to count the number of rows where both Column A
> > and Column B have a date between 01-01-05 and 12-31-05

>
> An alternative to try, presuming data in cols A and B are all real dates:
> =SUMPRODUCT((TEXT(A1:A4,"yyyy")="2005")*(TEXT(B1:B4,"yyyy")="2005"))
> Adapt the ranges to suit the actual extents. Any joy? hit the YES below
> --
> Max
> Singapore
> xde
> ---

 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      30th Nov 2009
> .. I also need it to work for date ranges between 02-01-05 and 01-31-06,
> so I can't limit it to just the year


Try it like this then, with explicit, unambiguous date ranges defined:
=SUMPRODUCT((A1:A4>=--"2 Jan 2005")*(A1:A4<=--"31 Jan 2006")*(B1:B4>=--"2
Jan 2005")*(B1:B4<=--"31 Jan 2006"))
Success? hit the YES below
--
Max
Singapore
xde
---
 
Reply With Quote
 
Luke M
Guest
Posts: n/a
 
      30th Nov 2009
What error is it spitting out? To explain, the "--" is there to convert the
results from the comparison (true/false) into numbers. The first "-" converts
it to (-1/0) and the second "-" converts it to (1/0). The 4 arrays are then
multipied across each other, and only when four 1's are found is an entry
counted.

Playing around with the formula as written, I am unable to get it to create
an error (even when text is used in some of the fields). Possible debugging
method would be to change the arrays that are being examined until you find
the area that is causing trouble?

Of final note, the array "sizes" must be identical. For instance, in the
formula I gave all arrays are 99 rows. Sorry this isn't more helpful.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Jennifer" wrote:

> Luke - this is returning an error when I enter it in exactly like you have
> it. When I change the "--" to "-", I get a returned value of 1, so it's
> still not pulling it correctly.
>
> "Luke M" wrote:
>
> > =SUMPRODUCT(--(A2:A100>C1),--(A2:A100<D1),--(B2:B100>C1),--(B2:B100<D1))
> >
> > Note that unless you are using XL 2007, you can't callout the entire column
> > within SUMPRODUCT.
> > --
> > Best Regards,
> >
> > Luke M
> > *Remember to click "yes" if this post helped you!*
> >
> >
> > "Jennifer" wrote:
> >
> > > I'm trying to count the number of rows that matches multiple criteria in
> > > multiple ranges. As an example, I want to count the number of rows where
> > > both Column A and Column B have a date between 01-01-05 and 12-31-05. Where:
> > >
> > > Column A Column B
> > > 01-02-05 12-20-05
> > > 01-06-05 02-20-06
> > > 05-06-09 03-07-05
> > > 01-02-06 01-09-06
> > >
> > > So, in this instance, I want it to count only row 1 because both columns
> > > match the criteria.
> > >
> > > I've tried a couple of different Countif statements, but I can never get it
> > > to count using the multiple criteria and ranges. Please assist.
> > >
> > > Things I've tried:
> > > =Countif(and(A:A,B:B), ">"&C1))+countif(and(A:A,B:B), "<"&D1) - - where C1
> > > is equal to 01-01-05 and D1 is 12-31-05
> > >

 
Reply With Quote
 
David Biddulph
Guest
Posts: n/a
 
      30th Nov 2009
What error is it reporting?
The formula is fine, so it sounds as if you tried to retype the formula and
got it wrong. Rather than retyping, copy it from the newsgroup and paste
into the formula bar on your spreadsheet.
--
David Biddulph

"Jennifer" <(E-Mail Removed)> wrote in message
news:7371B22A-C458-4CA7-AF05-(E-Mail Removed)...
> Luke - this is returning an error when I enter it in exactly like you have
> it. When I change the "--" to "-", I get a returned value of 1, so it's
> still not pulling it correctly.
>
> "Luke M" wrote:
>
>> =SUMPRODUCT(--(A2:A100>C1),--(A2:A100<D1),--(B2:B100>C1),--(B2:B100<D1))
>>
>> Note that unless you are using XL 2007, you can't callout the entire
>> column
>> within SUMPRODUCT.
>> --
>> Best Regards,
>>
>> Luke M
>> *Remember to click "yes" if this post helped you!*
>>
>>
>> "Jennifer" wrote:
>>
>> > I'm trying to count the number of rows that matches multiple criteria
>> > in
>> > multiple ranges. As an example, I want to count the number of rows
>> > where
>> > both Column A and Column B have a date between 01-01-05 and 12-31-05.
>> > Where:
>> >
>> > Column A Column B
>> > 01-02-05 12-20-05
>> > 01-06-05 02-20-06
>> > 05-06-09 03-07-05
>> > 01-02-06 01-09-06
>> >
>> > So, in this instance, I want it to count only row 1 because both
>> > columns
>> > match the criteria.
>> >
>> > I've tried a couple of different Countif statements, but I can never
>> > get it
>> > to count using the multiple criteria and ranges. Please assist.
>> >
>> > Things I've tried:
>> > =Countif(and(A:A,B:B), ">"&C1))+countif(and(A:A,B:B), "<"&D1) - -
>> > where C1
>> > is equal to 01-01-05 and D1 is 12-31-05
>> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting a number of cells with 2 range criteria Garf Microsoft Excel Misc 3 19th Jun 2009 09:43 AM
Counting cells in a range per multiple criteria . . . Dano Microsoft Excel Worksheet Functions 10 19th May 2008 05:28 PM
Counting from one range to another range, multiple criteria =?Utf-8?B?bWFjYW1hcnI=?= Microsoft Excel Misc 3 10th Jun 2006 11:02 AM
Counting Cells with multiple criteria.One criteria supporting wild =?Utf-8?B?QXpoYXIgQXJhaW4=?= Microsoft Excel Worksheet Functions 1 12th Jan 2005 08:33 AM
Counting Cells with multiple criteria.One criteria supporting wild =?Utf-8?B?QXpoYXIgU2FsZWVt?= Microsoft Excel Worksheet Functions 0 12th Jan 2005 07:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:07 PM.