Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default COUNTIF formula in multiple columns

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default COUNTIF formula in multiple columns

You need to use the SUMPRODUCT function.

=SUMPRODUCT((A1:A10="girl"),(B1:B10=6))

=SUMPRODUCT((A1:A10="girl),(B1:B10=6),(C1:C10="Lon don"))

Dave

--
Brevity is the soul of wit.


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default COUNTIF formula in multiple columns

Try something like this:

With
A1:A20 contains girl or boy values
B1:B20 contains age values
C1:C20 contains city names

AND
F1: girl
G1: 6
H1: London

This formula counts the records that match all 3 criteria:
I1: =SUMPRODUCT((A1:A20=F1)*(B1:B20=G1)*(C1:C20=H1))

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default COUNTIF formula in multiple columns

I knew I screwed up the formula I gave. Ron's is correct. You need the
asterisk (*) not the comma....

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Try something like this:

With
A1:A20 contains girl or boy values
B1:B20 contains age values
C1:C20 contains city names

AND
F1: girl
G1: 6
H1: London

This formula counts the records that match all 3 criteria:
I1: =SUMPRODUCT((A1:A20=F1)*(B1:B20=G1)*(C1:C20=H1))

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default COUNTIF formula in multiple columns

Replace the comma with an asterisk, *

Sorry...
--
Brevity is the soul of wit.


"Dave F" wrote:

You need to use the SUMPRODUCT function.

=SUMPRODUCT((A1:A10="girl"),(B1:B10=6))

=SUMPRODUCT((A1:A10="girl),(B1:B10=6),(C1:C10="Lon don"))

Dave

--
Brevity is the soul of wit.


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default COUNTIF formula in multiple columns

Actually, you can use the commas if you prefer, BUT you need to coeerce the
boolean (true/false) values to numeric, using the dbl-negative (--):

Your posted formula would need to be
=SUMPRODUCT(--(A1:A10="girl"),--(B1:B10=6),--(C1:C10="London"))

***********
Regards,
Ron

XL2002, WinXP


"Dave F" wrote:

I knew I screwed up the formula I gave. Ron's is correct. You need the
asterisk (*) not the comma....

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Try something like this:

With
A1:A20 contains girl or boy values
B1:B20 contains age values
C1:C20 contains city names

AND
F1: girl
G1: 6
H1: London

This formula counts the records that match all 3 criteria:
I1: =SUMPRODUCT((A1:A20=F1)*(B1:B20=G1)*(C1:C20=H1))

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default COUNTIF formula in multiple columns

Right, but it seems to me that using the asterisk makes for a more concise,
easy to understand formula. I know others are fans of the -- though.

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Actually, you can use the commas if you prefer, BUT you need to coeerce the
boolean (true/false) values to numeric, using the dbl-negative (--):

Your posted formula would need to be
=SUMPRODUCT(--(A1:A10="girl"),--(B1:B10=6),--(C1:C10="London"))

***********
Regards,
Ron

XL2002, WinXP


"Dave F" wrote:

I knew I screwed up the formula I gave. Ron's is correct. You need the
asterisk (*) not the comma....

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Try something like this:

With
A1:A20 contains girl or boy values
B1:B20 contains age values
C1:C20 contains city names

AND
F1: girl
G1: 6
H1: London

This formula counts the records that match all 3 criteria:
I1: =SUMPRODUCT((A1:A20=F1)*(B1:B20=G1)*(C1:C20=H1))

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default COUNTIF formula in multiple columns

Thank you very much to you both. It works marvellously!
--
NitaMax


"Ron Coderre" wrote:

Actually, you can use the commas if you prefer, BUT you need to coeerce the
boolean (true/false) values to numeric, using the dbl-negative (--):

Your posted formula would need to be
=SUMPRODUCT(--(A1:A10="girl"),--(B1:B10=6),--(C1:C10="London"))

***********
Regards,
Ron

XL2002, WinXP


"Dave F" wrote:

I knew I screwed up the formula I gave. Ron's is correct. You need the
asterisk (*) not the comma....

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Try something like this:

With
A1:A20 contains girl or boy values
B1:B20 contains age values
C1:C20 contains city names

AND
F1: girl
G1: 6
H1: London

This formula counts the records that match all 3 criteria:
I1: =SUMPRODUCT((A1:A20=F1)*(B1:B20=G1)*(C1:C20=H1))

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default COUNTIF formula in multiple columns

Regarding:
Right, but it seems to me that using the asterisk makes for a more concise,
easy to understand formula. I know others are fans of the -- though.


I agree...most users understand the asterisk as a multiplication operator.
The purpose of the dbl-neg is not always so apparent. I only use it in
special circumstances when I need it.

***********
Regards,
Ron

XL2002, WinXP


"Dave F" wrote:

Right, but it seems to me that using the asterisk makes for a more concise,
easy to understand formula. I know others are fans of the -- though.

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Actually, you can use the commas if you prefer, BUT you need to coeerce the
boolean (true/false) values to numeric, using the dbl-negative (--):

Your posted formula would need to be
=SUMPRODUCT(--(A1:A10="girl"),--(B1:B10=6),--(C1:C10="London"))

***********
Regards,
Ron

XL2002, WinXP


"Dave F" wrote:

I knew I screwed up the formula I gave. Ron's is correct. You need the
asterisk (*) not the comma....

Dave
--
Brevity is the soul of wit.


"Ron Coderre" wrote:

Try something like this:

With
A1:A20 contains girl or boy values
B1:B20 contains age values
C1:C20 contains city names

AND
F1: girl
G1: 6
H1: London

This formula counts the records that match all 3 criteria:
I1: =SUMPRODUCT((A1:A20=F1)*(B1:B20=G1)*(C1:C20=H1))

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"NitaMax" wrote:

I have Gender, Age and City columns.
I need a COUNTIF formula that will enable me to count, for example:

- number of girls, aged 6
- number of girls, aged 6 and from London

The formula I used for the gender is =COUNTIF(D2:D482,"G").

So far, my efforts to adapt this have been fruitless.

Any help would be grately appreciated.

--
NitaMax

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF across Multiple Rows and Columns [email protected] Excel Worksheet Functions 1 September 1st 06 01:49 AM
Countif Formula /Sort Bug??? orcfodder Excel Discussion (Misc queries) 2 January 12th 06 10:04 AM
Multiple COUNTIF formula JaB Excel Discussion (Misc queries) 2 September 29th 05 07:30 PM
adding row to forumla carrera Excel Discussion (Misc queries) 9 August 23rd 05 10:24 PM
Adding columns (one with a formula) PaulStroik New Users to Excel 7 June 27th 05 10:32 PM


All times are GMT +1. The time now is 09:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"