Add numbers that are part of a string in cells

cyberdimitri

New Member
Joined
Nov 4, 2012
Messages
49
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm trying to add the numbers that are part of a string in a row of a table.

So, for the table below, I want some formulas in the cells A4:A9 that add all the numbers in the cells of row 1 that start with the same letter.
1658231455251.png

Please note that I need the cells that start with "AS" to be distinguished from the cells that start with "A".
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Maybe
Excel Formula:
=SUMPRODUCT((LEFT($A$1:$M$1,LEN(A4))=A4)*(IFERROR(MID($A$1:$M$1,LEN(A4)+1,100)+0,0)))
 
Upvote 0
Solution
What version of Excel do you used? I suggest you update your profile to show it. The solution could be different for the newest version of Excel vs. older versions.
 
Upvote 0
A simple 365 solution.
MrExcelPlayground10.xlsx
ABCDEFGHIJKLM
1AS1A11D23F41Q1A2A44A12S12Q11AS21D3S11
2
31112341124412121121311
4ASADFQAAASQASDS
5
6A69
7AS22
8D26
9F41
10Q12
11S23
Sheet16
Cell Formulas
RangeFormula
A3:M3A3=MAX(IFERROR(VALUE(RIGHT(A1,SEQUENCE(LEN(A1)))),0))
A4:M4A4=LEFT(A1,LEN(A1)-LEN(A3))
A6:A11A6=SORT(UNIQUE(TRANSPOSE(A4:M4)))
B6:B11B6=SUMIFS(A3:M3,A4:M4,A6#)
Dynamic array formulas.
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Maybe
Excel Formula:
=SUMPRODUCT((LEFT($A$1:$M$1,LEN(A4))=A4)*(IFERROR(MID($A$1:$M$1,LEN(A4)+1,100)+0,0)))
Thanks, it worked! I also updated my account details, thanks for the suggestion!
I really appreciate your time and I may be taking advantage of your kindness by asking what the "100" in the formula does, not necessary for me to know, but I'd like to learn.
 
Upvote 0
What version of Excel do you used? I suggest you update your profile to show it. The solution could be different for the newest version of Excel vs. older versions.
Hey, thanks for the suggestion, I use Office 365 on a Windows PC. I updated my profile to show this.
A simple 365 solution.
MrExcelPlayground10.xlsx
ABCDEFGHIJKLM
1AS1A11D23F41Q1A2A44A12S12Q11AS21D3S11
2
31112341124412121121311
4ASADFQAAASQASDS
5
6A69
7AS22
8D26
9F41
10Q12
11S23
Sheet16
Cell Formulas
RangeFormula
A3:M3A3=MAX(IFERROR(VALUE(RIGHT(A1,SEQUENCE(LEN(A1)))),0))
A4:M4A4=LEFT(A1,LEN(A1)-LEN(A3))
A6:A11A6=SORT(UNIQUE(TRANSPOSE(A4:M4)))
B6:B11B6=SUMIFS(A3:M3,A4:M4,A6#)
Dynamic array formulas.
Hey James, Thanks for your answer! I didn't test it as Fluff's solution worked perfectly, but I do appreciate your time!
 
Upvote 0
The 100 is just an arbitrary number to get everything in the cell after the start point.
As you have xl365 you could also use the formula in A4 to get the letters & another option in C4 for the sums

Fluff.xlsm
ABCDEFGHIJKLM
1AS1A11D23F41Q1A2A44A12S12Q11AS21D3S11
2
3
4A6969
5AS2222
6D2626
7F4141
8Q1212
9S2323
10
Data
Cell Formulas
RangeFormula
A4:A9A4=SORT(UNIQUE(TRANSPOSE(LEFT(A1:M1,1+ISERR(MID(A1:M1,2,1)+0)))))
B4:B9B4=SUMPRODUCT((LEFT($A$1:$M$1,LEN(A4))=A4)*(IFERROR(MID($A$1:$M$1,LEN(A4)+1,100)+0,0)))
C4:C9C4=SUM(IFERROR(FILTER(MID($A$1:$M$1,LEN(A4)+1,100),LEFT($A$1:$M$1,LEN(A4))=A4)+0,0))
Dynamic array formulas.
 
Upvote 0
Another option to consider for the sums

22 07 19.xlsm
ABCDEFGHIJKLM
1AS1A11D23F41Q1A2A44A12S12Q11AS21D3S11
2
3
4A69
5AS22
6D26
7F41
8Q12
9S23
Sum
Cell Formulas
RangeFormula
B4:B9B4=SUM(IFERROR(SUBSTITUTE(A$1:M$1,A4,"",1)+0,0))
 
Upvote 0
Here is an alternate solution using Power Query. Excel offers up multiple means to the end.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Transposed Table" = Table.Transpose(Source),
    #"Split Column by Character Transition" = Table.SplitColumn(#"Transposed Table", "Column1", Splitter.SplitTextByCharacterTransition((c) => not List.Contains({"0".."9"}, c), {"0".."9"}), {"Column1.1", "Column1.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Character Transition",{{"Column1.2", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Column1.1"}, {{"Sum", each List.Sum([Column1.2]), type nullable text}})
in
    #"Grouped Rows"
 
Upvote 0
Here is an alternate solution using Power Query. Excel offers up multiple means to the end.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Transposed Table" = Table.Transpose(Source),
    #"Split Column by Character Transition" = Table.SplitColumn(#"Transposed Table", "Column1", Splitter.SplitTextByCharacterTransition((c) => not List.Contains({"0".."9"}, c), {"0".."9"}), {"Column1.1", "Column1.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Character Transition",{{"Column1.2", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Column1.1"}, {{"Sum", each List.Sum([Column1.2]), type nullable text}})
in
    #"Grouped Rows"
Wow, I got dizzy just looking at your solution, I wish I could be as fluent in excel as you guys are. Thanks for your answer, I didn't try it because Fluff's solution works perfectly and it was a one-liner, but I appreciate the effort!
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

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