Best way to sum numbers after specific text in a column

kcmuppet

Active Member
Joined
Nov 2, 2005
Messages
439
Office Version
  1. 365
Platform
  1. Windows
What would be the best way to sum the numbers in a column that follow specific text?
In the example below, I want to add the numbers following "K" and those following "GM"

Brooks_Sports_Global_Factory_List_Dec_2022.xlsx
AB
1K2
2GM3,K1
3K1, GM2
4
5Total K4
6Total GM5
Sheet2
 
Assuming the set up you show in Message #5, give this a try...

=SUM(0+TEXTBEFORE(TEXTAFTER(C$1:C$3&","&B5&0,B5)&",",",",1))
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Assuming the set up you show in Message #5, give this a try...

=SUM(0+TEXTBEFORE(TEXTAFTER(C$1:C$3&","&B5&0,B5)&",",",",1))
Thanks for this idea, Rick.

Trying to understand it from the inside out:
Excel Formula:
TEXTAFTER(C$1:C$3&","&B5&0,B5)
gives us this list:
2,K0
1,K0
1, GM2,K0

Then this bit...
Excel Formula:
TEXTBEFORE(list above&",",",",1)
...takes the text before each of those items and any comma that follows them?
I'm struggling a bit with how that works
 
Upvote 0
Thanks for this idea, Rick.

Trying to understand it from the inside out:
Excel Formula:
TEXTAFTER(C$1:C$3&","&B5&0,B5)
gives us this list:
2,K0
1,K0
1, GM2,K0

Then this bit...
Excel Formula:
TEXTBEFORE(list above&",",",",1)
...takes the text before each of those items and any comma that follows them?
I'm struggling a bit with how that works
The comma is concatenated at the end of the list to cover cells without commas so TEXTBEFORE has a comma to find... then TEXTBEFORE returns the text before the **first** comma it finds... this will be the sought after number or 0 which was supplied as part of the TEXTAFTER when the delimiter was not present in the text.
 
Upvote 1
The comma is concatenated at the end of the list to cover cells without commas so TEXTBEFORE has a comma to find... then TEXTBEFORE returns the text before the **first** comma is finds... this will be the sought after number or 0 which was supplied as part of the TEXTAFTER when the delimiter was not present in the text.
Thanks! Also Ingenious!
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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