Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Excel - sum values in one column, based on string in another column

Posted on 2011-10-17
8
Medium Priority
?
195 Views
Last Modified: 2012-06-27
Let's say I have the following -- 6 rows, 2 columns.

I want to report in 3 other separate cells, sums:
Total everything from ColB, where ColA has an Aa (example would report 8)
Total everything from ColB, where ColA has an Bb (example would report 10)
Total everything from ColB, where ColA has an Cc (example would report 3)

Thanks for your help!



.....A.....B
1....Aa....2
2....Bb....1
3....Cc....3
4....Bb....5
5....Bb....4
6....Aa....6

Open in new window

0
Comment
Question by:blakogre
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 36982138
a simple SUMPRODUCT() formula like this would do the trick:

=SUMPRODUCT(($A$1:$A$6=D1)*($B$1:$B$6))

jppinto
0
 
LVL 33

Expert Comment

by:jppinto
ID: 36982141
Please take a look at the attached working example.

jppinto
SUMPRODUCT-Example5.xlsx
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 total points
ID: 36982149
Does it need to be case-sensitive?

You can use SUMIF which isn't case-sensitive, e.g.

=SUMIF(A1:A6,"Aa",B1:B6)

but, like I say, that will sum col B if A is "AA" or "aa"

For case-sensitive

=SUMPRODUCT(EXACT(A1:A6,"Aa")+0,B1:B6)

regards, barry
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Author Comment

by:blakogre
ID: 36982275
It doesn't need to be case sensitive.  SumIf seems the simplest solution.  Not sure if/why sumproduct (first answer) would be a better choice?
0
 
LVL 9

Author Comment

by:blakogre
ID: 36982293
barryhoudini's is working fine for me, so no other solutions are necessary -- just keeping open until i get a response on last post.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 36982329
For a small amount of data it probably doesn't matter which you use but SUMIF is more efficient than SUMPRODUCT (by some distance) so is preferable when you have the choice.

regards, barry
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36984371
NFP:

If the data is in the same workbook as the summary, definitely use SUMIF. If not, you would need SUMPRODUCT.
0
 
LVL 33

Expert Comment

by:jppinto
ID: 36987693
Don't know why you didn't liked my solution as it was working fine, I even gave you a working file for you to check!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question