Solved

Sum matching rows to another sheet

Posted on 2011-03-02
8
266 Views
Last Modified: 2012-06-27
Hello Experts,

Here is what I have
SHEET 1
Name	ID	Pay
Mark	101	10
Phil	102	8
Dave	103	4
Mark	101	19
Dawn	104	4
Bob	105	60
Mark	101	7
Les	106	22
Dawn	104	31
Phil	102	40
Dave	103	11
Al	107	3
Les	106	12

Open in new window


I also have this in another sheet
SHEET 2
Name	ID     Pay  
Mark	101
Phil	102
Dave	103
Dawn	104
Bob	105
Les	106
Al	107

Open in new window


What I would like to do is fill in the Pay on SHEET 2 with the SUM of all the matching rows on SHEET1.  I assume a VLOOKUP on the ID would be best.
This is what SHEET2 will look like:
Name	ID	Pay
Mark	101	36
Phil	102	48
Dave	103	15
Dawn	104	35
Bob	105	60
Les	106	34
Al	107	3

Open in new window




I would like to know the simple formula that does it AND if there is a VB that will do it too.  I will use the formula, but I am learning VB and would like to see that too if possible.

THANKS!!!!
0
Comment
Question by:Mark Harris
  • 5
  • 2
8 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 35020621
Please check the attached example.

jppinto
Book1.xlsx
0
 
LVL 33

Expert Comment

by:jppinto
ID: 35020632
This is the formula to put on the first row under Pay:

=SUMPRODUCT((Sheet1!$A$2:$A$14=Sheet2!A2)*(Sheet1!$B$2:$B$14=Sheet2!B2)*(Sheet1!$C$2:$C$14))

Then copy down the column.

jppinto
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 35021092
Would SUMIF be sufficient, I assume the IDs are unique. In sheet 2 C2 copied down

=SUMIF(Sheet1!B:B,B2,Sheet1!C:C)

regards, barry
0
 
LVL 33

Expert Comment

by:jppinto
ID: 35021496
@fireman7147: did you at least took a look at my example?!? My formula works and gives the result that you wanted. I posted a working solution first and you accepted only the solution from barry?!

Please explain...
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 50

Expert Comment

by:barry houdini
ID: 35021643
With respect jppinto, why would you need SUMPRODUCT here, SUMIF is always preferable for a single condition? I note that fireman7147 asked for a "simple formula", and that's what I provided - the first solution posted isn't necessarily the best!

regards, barry
0
 
LVL 33

Expert Comment

by:jppinto
ID: 35022685
Barry, with all due respect, you can use SUMIF here but you can also use SUMPRODUCT and it works. There are many ways of doing this. These are only two. I still think that at least my answer should be accepted as an "assist" because it works and I posted a working solution first. Maybe it's not the best solution, but still is a solution!

I would like to ear the explanation from the author here also...

regards,

jppinto
0
 

Author Comment

by:Mark Harris
ID: 35023582
@jppinto
Your solution worked indeed, but only if I had exactly the amount of rows in the example. Barry's solution worked with unlimited rows, which will be the case.

Sorry if you feel slighted, but his solution appeared to be the simplest and the most versatile. Any slight to you was unintentional.

Thanks Mark
0
 
LVL 33

Expert Comment

by:jppinto
ID: 35025409
OK, thanks for your feedback. No hard feelings. Maybe next time I get it :)

regards,

jppinto
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now