#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JRD JRD is offline
external usenet poster
 
Posts: 60
Default counting

How do I count the number of cells in column A that contain a certain string
but only if the same row in column B contains a certain string

eg

A B
Elective Yes
Elective No
Urgent Yes
Urgent No
Elective Yes

How do I count the number of rows that contain Elective in column A and Yes
in column B. The answer here would be 2.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,572
Default counting

Try this:

=Sumproduct((A1:A5="Elective")*(B1:B5="Yes"))

--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===

"JRD" wrote in message
...
How do I count the number of cells in column A that contain a certain string
but only if the same row in column B contains a certain string

eg

A B
Elective Yes
Elective No
Urgent Yes
Urgent No
Elective Yes

How do I count the number of rows that contain Elective in column A and Yes
in column B. The answer here would be 2.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default counting

Try this:

=SUMPRODUCT(--(A1:A5="Elective"),--(B1:B5="Yes"))

Better to use cells to hold the criteria.

D1 = Elective
E1 = Yes

=SUMPRODUCT(--(A1:A5=D1),--(B1:B5=E1))

--
Biff
Microsoft Excel MVP


"JRD" wrote in message
...
How do I count the number of cells in column A that contain a certain
string
but only if the same row in column B contains a certain string

eg

A B
Elective Yes
Elective No
Urgent Yes
Urgent No
Elective Yes

How do I count the number of rows that contain Elective in column A and
Yes
in column B. The answer here would be 2.



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JRD JRD is offline
external usenet poster
 
Posts: 60
Default counting

Thanks

Can you tell me what -- does before the paratheses?

John

"T. Valko" wrote:

Try this:

=SUMPRODUCT(--(A1:A5="Elective"),--(B1:B5="Yes"))

Better to use cells to hold the criteria.

D1 = Elective
E1 = Yes

=SUMPRODUCT(--(A1:A5=D1),--(B1:B5=E1))

--
Biff
Microsoft Excel MVP


"JRD" wrote in message
...
How do I count the number of cells in column A that contain a certain
string
but only if the same row in column B contains a certain string

eg

A B
Elective Yes
Elective No
Urgent Yes
Urgent No
Elective Yes

How do I count the number of rows that contain Elective in column A and
Yes
in column B. The answer here would be 2.






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,572
Default counting

Sumproduct works with logicals (True, False), so the double unary ( -- )
converts them to numbers (True=1, False=0) so the returns can be calculated.

Check out these web sites for further explanations:

http://www.mcgimpsey.com/excel/formulae/doubleneg.html

http://www.xldynamic.com/source/xld.SUMPRODUCT.html

If you'll notice, my suggested formula uses the multiplication operator (
* ) to accomplish the same result.
--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"JRD" wrote in message
...
Thanks

Can you tell me what -- does before the paratheses?

John

"T. Valko" wrote:

Try this:

=SUMPRODUCT(--(A1:A5="Elective"),--(B1:B5="Yes"))

Better to use cells to hold the criteria.

D1 = Elective
E1 = Yes

=SUMPRODUCT(--(A1:A5=D1),--(B1:B5=E1))

--
Biff
Microsoft Excel MVP


"JRD" wrote in message
...
How do I count the number of cells in column A that contain a certain
string
but only if the same row in column B contains a certain string

eg

A B
Elective Yes
Elective No
Urgent Yes
Urgent No
Elective Yes

How do I count the number of rows that contain Elective in column A

and
Yes
in column B. The answer here would be 2.





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
counting function but not double counting duplicates JRD Excel Worksheet Functions 2 November 7th 07 06:43 PM
Counting Mark Excel Worksheet Functions 6 March 8th 07 01:47 AM
counting chiapas77 Excel Worksheet Functions 4 March 6th 06 09:47 PM
Counting rows, then counting values. Michael via OfficeKB.com Excel Discussion (Misc queries) 7 August 4th 05 10:57 PM
Counting names in a column but counting duplicate names once TBoe Excel Discussion (Misc queries) 9 May 11th 05 11:24 PM


All times are GMT +1. The time now is 05:14 PM.

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"