Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Adding numerical values based on multiple values in another column

Please help
I am trying to add numerical values in one column based on multiple values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a value of
red and green in column A. Thank you in advance for your help!

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,268
Default Adding numerical values based on multiple values in another column

A couple of ways

=SUM(SUMIF(A2:A6,{"Red";"Green"},B2:B6))

or

=SUMPRODUCT(--((A2:A6="Red")+(A2:A6="Green")0),B2:B6)

both returns 57


--
Regards,

Peo Sjoblom



"Kazmaniac" wrote in message
...
Please help
I am trying to add numerical values in one column based on multiple values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a value
of
red and green in column A. Thank you in advance for your help!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Adding numerical values based on multiple values in another column

=SUMPRODUCT((A2:A6={"Red","Green"})*B2:B6)

"Kazmaniac" wrote:

Please help
I am trying to add numerical values in one column based on multiple values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a value of
red and green in column A. Thank you in advance for your help!

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Adding numerical values based on multiple values in another co

THANK YOU!!!!! WORKS LIKE A CHARM!!!

"Peo Sjoblom" wrote:

A couple of ways

=SUM(SUMIF(A2:A6,{"Red";"Green"},B2:B6))

or

=SUMPRODUCT(--((A2:A6="Red")+(A2:A6="Green")0),B2:B6)

both returns 57


--
Regards,

Peo Sjoblom



"Kazmaniac" wrote in message
...
Please help
I am trying to add numerical values in one column based on multiple values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a value
of
red and green in column A. Thank you in advance for your help!




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default Adding numerical values based on multiple values in another column

Why not just
=SUMPRODUCT((A1:A5="red")+(A1:A5="green"),B1:B5)
No need for "- -" since the addition operator will coerce logical values to
numeric
No need for "0" since 0 * anything = 0
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Peo Sjoblom" wrote in message
...
A couple of ways

=SUM(SUMIF(A2:A6,{"Red";"Green"},B2:B6))

or

=SUMPRODUCT(--((A2:A6="Red")+(A2:A6="Green")0),B2:B6)

both returns 57


--
Regards,

Peo Sjoblom



"Kazmaniac" wrote in message
...
Please help
I am trying to add numerical values in one column based on multiple
values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a value
of
red and green in column A. Thank you in advance for your help!







  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,268
Default Adding numerical values based on multiple values in another column

The reason I use it is because I want to be fairly consistent, if for
instance the OP had asked Green OR Red in A2:B5 then sum C2:C5. If for
instance A2 holds red and B2 holds green your formula would do 2 x C2 while
mine would do
1 x C2


--
Regards,

Peo Sjoblom


"Bernard Liengme" wrote in message
...
Why not just
=SUMPRODUCT((A1:A5="red")+(A1:A5="green"),B1:B5)
No need for "- -" since the addition operator will coerce logical values
to numeric
No need for "0" since 0 * anything = 0
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Peo Sjoblom" wrote in message
...
A couple of ways

=SUM(SUMIF(A2:A6,{"Red";"Green"},B2:B6))

or

=SUMPRODUCT(--((A2:A6="Red")+(A2:A6="Green")0),B2:B6)

both returns 57


--
Regards,

Peo Sjoblom



"Kazmaniac" wrote in message
...
Please help
I am trying to add numerical values in one column based on multiple
values
in another column.

A B
Red $24
Blue $16
Green $21
Blue $15
Green $12

I would like to add the values in column B for all rows that have a
value of
red and green in column A. Thank you in advance for your help!







  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Adding numerical values based on multiple values in another column

"Bernard Liengme" wrote...
Why not just
=SUMPRODUCT((A1:A5="red")+(A1:A5="green"),B1:B5 )
No need for "- -" since the addition operator will coerce logical
values to numeric

....

For another reason,

=SUM(SUMIF(A1:A5,{"red";"green"},B1:B5))

is more efficient both in terms of storage and recalc speed. And it's
more general (not that this is an issue in this instance), i.e.,

=SUM(SUMIF(A:A,{"red";"green"},B:B))

works, while

=SUMPRODUCT((A:A="red")+(A:A="green"),B:B)

will fail in XL2003 and prior versions.

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
help me on rearrange cells based on its numerical values without repeating any number amrezzat Excel Worksheet Functions 0 November 21st 05 11:01 PM
Return Range of Numerical Values in Single Column based on Frequency Percentage Sam via OfficeKB.com Excel Worksheet Functions 9 October 28th 05 11:01 PM
Extract one numerical value from single cell with multiple values? cszy67 Excel Worksheet Functions 2 July 27th 05 02:49 AM
Formula to compare multiple rows values based on another column? Murph Excel Worksheet Functions 4 February 21st 05 02:44 AM
Adding Values Based on a Separate Column binder Excel Discussion (Misc queries) 2 February 14th 05 07:17 PM


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