Group sum based on the Ascending order of the number

vasu2007

New Member
Joined
Nov 16, 2014
Messages
9
Office Version
  1. 2019
Platform
  1. Windows
Hello Experts,

I need to sum the numbers in col "B" based on the locations in Col "A", but is in increasing order.

COL#A COL#B
A - 1
A - 1
B - 2
B - 1
C - 3
C - 1

OUT PUT:
C(4)+B(3)+A(2) = 9

C+B+A should be in ascending order based on the sum in column B. This is the tricky part.
I have searched for this kind of requirement, but unable to find

Data & output is given in Below Picture.

Please help. Thanks in advance.

Consolidate.xlsx
ABCDEFGH
1LocationValueOUTPUTSL NOLOCATIONSum
2A11B+A+C17.5
3C0.82A+B+D+C49.9
4A4.73A+D+B+C65.9
5B11
617.5
7D1.3
8D4.5
9C4.8
10A31.4
11B4.9
12B1.3
13B1.7
1449.9
15C4.5
16C0.7
17B15.9
18D3.7
19D2.2
20D14.8
21A24.1
2265.9
Sheet1
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Is there a specific value range in col b? i.e LocationA-1 has a value of 1 to 10 Location A-2 has a value of 11 to 20 etc?
 
Upvote 0
How do you ascertain the Location codes (e.g. A+B+C)? The reason I ask, is if they were a result of another lookup or similar then it might be possible, but without doing a repeated SUMIF, with your version of Excel it would be difficult to get a useful answer!

Excel Formula:
=SUMPRODUCT($B$3:$B$22*($A$3:$A$22={"A","B","C"}))

This formula would work if you were hand typing in the Location IDs to the formula, but without VBA to auto-generate that formula it would be difficult to have it work each time a user entered location values. Excel 2019 doesn't recognise arrays typed into a cell unfortunately.

Edit: I should add, that if you had a limited number of locations, you could just add those to individual columns (i.e. columns labelled Location1, Location2...Location5 etc). Then the following would work:

Book1
ABCDEFGHIJKL
1LocationValueOUTPUTSL NOLOCATIONSum
2
3A11A+B+CABCNone106.8
4C0.82A+B+D+CABDC133.3
5A4.73A+D+B+CADBC133.3
6B11
717.5
8D1.3
9D4.5
10C4.8
11A31.4
12B4.9
13B1.3
14B1.7
1549.9
16C4.5
17C0.7
18B15.9
19D3.7
20D2.2
21D14.8
22A24.1
Sheet1
Cell Formulas
RangeFormula
L3:L5L3=SUMPRODUCT($B$3:$B$22*($A$3:$A$22=H3:K3))
 
Last edited:
Upvote 0
How do you ascertain the Location codes (e.g. A+B+C)? The reason I ask, is if they were a result of another lookup or similar then it might be possible, but without doing a repeated SUMIF, with your version of Excel it would be difficult to get a useful answer!

Excel Formula:
=SUMPRODUCT($B$3:$B$22*($A$3:$A$22={"A","B","C"}))

This formula would work if you were hand typing in the Location IDs to the formula, but without VBA to auto-generate that formula it would be difficult to have it work each time a user entered location values. Excel 2019 doesn't recognise arrays typed into a cell unfortunately.

Edit: I should add, that if you had a limited number of locations, you could just add those to individual columns (i.e. columns labelled Location1, Location2...Location5 etc). Then the following would work:

Book1
ABCDEFGHIJKL
1LocationValueOUTPUTSL NOLOCATIONSum
2
3A11A+B+CABCNone106.8
4C0.82A+B+D+CABDC133.3
5A4.73A+D+B+CADBC133.3
6B11
717.5
8D1.3
9D4.5
10C4.8
11A31.4
12B4.9
13B1.3
14B1.7
1549.9
16C4.5
17C0.7
18B15.9
19D3.7
20D2.2
21D14.8
22A24.1
Sheet1
Cell Formulas
RangeFormula
L3:L5L3=SUMPRODUCT($B$3:$B$22*($A$3:$A$22=H3:K3))
Thank you for your response.
6th, 14th & 22nd rows are subtotals. or Where there is a blank cell in A column, that sum should be reflected against A+B+C.
ie., A,B,C locations should be concatenated & their corresponding sum should be reflected as shown in output.
It can be done by using VBA only as some complicated logic is involved.
 
Upvote 0
I think I understand what you're looking for now. My apologies. SL 1 refers to the first blank sum, SL 2 to the second blank sum, and so on. You want to return the blank row subtotals, and which locations that they subtotal (everything above/between the blank rows). That would be quite easy with unique and filter functions! I might get more time to look at it tomorrow, but it should be possible in Excel 2019 too.
I'm guessing that you can't receive the data in a different format, or access the original data source? That would always be my first suggestion.
 
Upvote 0
Hello Experts,

I need to sum the numbers in col "B" based on the locations in Col "A", but is in increasing order.

COL#A COL#B
A - 1
A - 1
B - 2
B - 1
C - 3
C - 1

OUT PUT:
C(4)+B(3)+A(2) = 9

C+B+A should be in ascending order based on the sum in column B. This is the tricky part.
I have searched for this kind of requirement, but unable to find

Data & output is given in Below Picture.

Please help. Thanks in advance.

Consolidate.xlsx
ABCDEFGH
1LocationValueOUTPUTSL NOLOCATIONSum
2A11B+A+C17.5
3C0.82A+B+D+C49.9
4A4.73A+D+B+C65.9
5B11
617.5
7D1.3
8D4.5
9C4.8
10A31.4
11B4.9
12B1.3
13B1.7
1449.9
15C4.5
16C0.7
17B15.9
18D3.7
19D2.2
20D14.8
21A24.1
2265.9
Sheet1
Hai Friends, Can some body help in writing the vba code please
 
Upvote 0

Forum statistics

Threads
1,215,329
Messages
6,124,302
Members
449,150
Latest member
NyDarR

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