Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
S2 S2 is offline
external usenet poster
 
Posts: 5
Default Counting values in one cell based on values in another

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Counting values in one cell based on values in another

=SUMPRODUCT(--(A1:A50=1),--(B1:B50="X"))
will give you what you what you want. Change 50 to the last row of your
data...

You can also try in E1
=SUMPRODUCT(--(A1:A50=C1),--(B1:B50=D1))
with 1 in C1, and X in D1

"S2" wrote:

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default Counting values in one cell based on values in another

=SUMPRODUCT(--(A2:A5&B2:B5="1X"))


"S2" wrote:

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)

  #4   Report Post  
Posted to microsoft.public.excel.misc
S2 S2 is offline
external usenet poster
 
Posts: 5
Default Counting values in one cell based on values in another

Thanks Sheeloo!

"Sheeloo" wrote:

=SUMPRODUCT(--(A1:A50=1),--(B1:B50="X"))
will give you what you what you want. Change 50 to the last row of your
data...

You can also try in E1
=SUMPRODUCT(--(A1:A50=C1),--(B1:B50=D1))
with 1 in C1, and X in D1


  #5   Report Post  
Posted to microsoft.public.excel.misc
S2 S2 is offline
external usenet poster
 
Posts: 5
Default Counting values in one cell based on values in another

Beautiful...& simple too! Thanks!

Quick q - what do the "--" mean/do?

"Teethless mama" wrote:

=SUMPRODUCT(--(A2:A5&B2:B5="1X"))


"S2" wrote:

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Counting values in one cell based on values in another

Be careful with this formula.

If you have 1X in A2 and B2 is empty or A2 is empty and B2 contains 1X, you may
not get the count you want.



Adjust the ranges to match--but you can't use whole columns (except in xl2007).

=sumproduct() likes to work with numbers. The -- stuff changes trues and falses
to 1's and 0's.

Bob Phillips explains =sumproduct() in much more detail he
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

And J.E. McGimpsey has some notes at:
http://mcgimpsey.com/excel/formulae/doubleneg.html

S2 wrote:

Beautiful...& simple too! Thanks!

Quick q - what do the "--" mean/do?

"Teethless mama" wrote:

=SUMPRODUCT(--(A2:A5&B2:B5="1X"))


"S2" wrote:

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Counting values in one cell based on values in another

Comparisons return True or False... when you put two minus signs in front
they are converted into 1 or 0... which then sumproduct adds up after
multiplying the paired values... hence the name SumProduct

"S2" wrote:

Beautiful...& simple too! Thanks!

Quick q - what do the "--" mean/do?

"Teethless mama" wrote:

=SUMPRODUCT(--(A2:A5&B2:B5="1X"))


"S2" wrote:

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default Counting values in one cell based on values in another

You're welcome!


"S2" wrote:

Beautiful...& simple too! Thanks!

Quick q - what do the "--" mean/do?

"Teethless mama" wrote:

=SUMPRODUCT(--(A2:A5&B2:B5="1X"))


"S2" wrote:

Greetings all -
I have the following data:
A B
1 Pri State
2 1 X
3 2
4 1
5 3 X

For each value (Priority) in ColA, I need to know how many times "X" occurs
in State (ColB)

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
Copy values from a cell based on values of another cell Spence10169 Excel Discussion (Misc queries) 4 January 13th 09 10:01 AM
Counting values based on multiple conditions Paul Excel Worksheet Functions 4 December 18th 08 08:01 PM
How to assign values to a cell based on values in another cell? Joao Lopes Excel Worksheet Functions 1 December 5th 07 09:02 PM
Counting based on values in two separate columns Wayne Excel Worksheet Functions 3 August 30th 06 07:43 PM
Counting based on values in two columns? Brother of Andrew Excel Worksheet Functions 4 November 18th 05 11:11 PM


All times are GMT +1. The time now is 04:04 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"