Extract and sum a range of cells based on a value from another sheet

LivingDawn

New Member
Joined
Aug 14, 2009
Messages
3
Hi all,

I love this site. I have gleened some great solutions from here to the many excel problems I have had over the years. But my current one is doing my head in.

I need to extract and sum a range of cells based on a value from another sheet that matches.

I have a summary worksheet [SALES SUMMARY] with a unique item code, description and the quantity sold.
Excel Workbook
ABC
1CodeDescriptionQty
2AKTS-880A-01XSample 13
3FGML-991B-001Sample 25
4VBCG-765A-65XSample 32
SALES SUMMARY


In another worksheet [TRANSACTIONS] I have a list of all of the transactions dumped from another application including unique item code, description, quantity sold per transaction and the total price.

Excel Workbook
ABCD
1CodeDescriptionQtyTotal
2AKTS-880A-01XSample 11$10.12
3AKTS-880A-01XSample 11$10.65
4AKTS-880A-01XSample 12$21.34
5AKTS-880A-01XSample 14$41.36
6AKTS-880A-01XSample 11$10.65
7AKTS-880A-01XSample 11$10.12
8AKTS-880A-01XSample 12$21.30
9AKTS-880A-01XSample 11$10.68
10FGML-991B-001Sample 21$ 2.42
11FGML-991B-001Sample 22$ 4.96
12FGML-991B-001Sample 21$ 2.55
13FGML-991B-001Sample 21$ 2.12
14FGML-991B-001Sample 23$ 6.69
15FGML-991B-001Sample 21$ 2.18
16FGML-991B-001Sample 21$ 2.24
17FGML-991B-001Sample 24$ 8.96
18FGML-991B-001Sample 22$ 4.84
19VBCG-765A-65XSample 31$ 1.12
20VBCG-765A-65XSample 43$ 3.42
21VBCG-765A-65XSample 51$ 1.18
22VBCG-765A-65XSample 62$ 2.38
23VBCG-765A-65XSample 71$ 1.24
24VBCG-765A-65XSample 81$ 1.12
25VBCG-765A-65XSample 91$ 1.16
26VBCG-765A-65XSample 102$ 2.40
27VBCG-765A-65XSample 112$ 2.38
TRANSACTIONS



e.g. So if I want the total value for the first 3 items sold of item code AKTS-880A-01X, I would get a list of:

CODE Description Qty Total
AKTS-880A-01X Sample 1 1 $10.12
AKTS-880A-01X Sample 1 1 $10.65
AKTS-880A-01X Sample 1 1 $10.67 (AKTS-880A-01X Sample 1 2 $21.34)*

Total $31.44

* this one is a quantity of 2, so the total would have to be divided by the quantity

I have tried to do formulas (I am using excel 2003) with the plan of doing a subtotal and extract those that are highlighted or tagged, and then I started to playing with VBA to try and accomplish it.. and failed dismally.

So if anyone can help it would be much appreciated.

Thanks
 
Can you base something around

=SUMPRODUCT((Transactions!A2:A27=SalesSummary!$A$2))

That would give you total for each item of code.

Not sure how you would limit the items though but its a start
 
Upvote 0
I know this approach is ugly, but it works. Hope someone can find an easy and elegant solution.
Excel Workbook
BCDEFGH
24AKTS-880A-01XSample 11$10.12CodeAKTS-880A-01X
25AKTS-880A-01XSample 11$10.65Total Amount31.44
26AKTS-880A-01XSample 12$21.34
27AKTS-880A-01XSample 14$41.36
28AKTS-880A-01XSample 11$10.65
29AKTS-880A-01XSample 11$10.12
30AKTS-880A-01XSample 12$21.30
31AKTS-880A-01XSample 11$10.68
32FGML-991B-001Sample 21$2.42
33FGML-991B-001Sample 22$4.96
34FGML-991B-001Sample 21$2.55
35FGML-991B-001Sample 21$2.12
36FGML-991B-001Sample 23$6.69
37FGML-991B-001Sample 21$2.18
38FGML-991B-001Sample 21$2.24
39FGML-991B-001Sample 24$8.96
40FGML-991B-001Sample 22$4.84
41VBCG-765A-65XSample 31$1.12
42VBCG-765A-65XSample 43$3.42
43VBCG-765A-65XSample 51$1.18
44VBCG-765A-65XSample 62$2.38
45VBCG-765A-65XSample 71$1.24
46VBCG-765A-65XSample 81$1.12
47VBCG-765A-65XSample 91$1.16
48VBCG-765A-65XSample 102$2.40
49VBCG-765A-65XSample 112$2.38
Sheet1
Excel 2007
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
 
Last edited:
Upvote 0
Ahh Brilliant... That works perfectly.

A very long formula. It may not be pretty, but it works brilliantly (and is way better than the mess I made)

Thanks wildcloud
 
Upvote 0

Forum statistics

Threads
1,226,852
Messages
6,193,364
Members
453,792
Latest member
Vic001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top