Extracting numbers from a string and adding them up

Vector8086

New Member
Joined
Jan 4, 2022
Messages
20
Office Version
  1. 365
  2. 2021
  3. 2016
  4. 2007
Platform
  1. Windows
  2. Web
I saw an old post where with the below formula to extract numbers from a string containing alphanumeric values - something like "p2, e(3), 15ip"

This will return: 2315.

My question is, can this be modified to return the sum of these numbers, i.e. 20? And can A1 be a range of cells where all the resulting numbers are added up?

Code:
B1: =SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$25),1))*
ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)

Thanks in advance!
V
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi,

Like this?
Excel Formula:
=SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$25),1))*ROW($1:$25),0),ROW($1:$25))+1,1)+0)
 
Upvote 0
Hi
Excel Formula:
=SUM(--TEXTSPLIT(TRIM(CONCAT(TEXT(MID(A1,SEQUENCE(99),1),"0,,0, ")))," "))
 
Upvote 0
Hi,

Like this?
Excel Formula:
=SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$25),1))*ROW($1:$25),0),ROW($1:$25))+1,1)+0)
Hi! Thanks for the help. This one is not adding the last number properly. I'm getting 11. It looks like it's adding only the single numbers. The sum should be 2+3+15 =20.
 
Upvote 0
Hi
Excel Formula:
=SUM(--TEXTSPLIT(TRIM(CONCAT(TEXT(MID(A1,SEQUENCE(99),1),"0,,0, ")))," "))
Thank you for the formula. My version of Excel (2016) doesn't seem to include the SEQUENCE function. So, I'm getting an error.
 
Upvote 0
Aahh you are looking for 15, not 1+5. Sorry. I don't know. Maybe you should wait for other replies.
 
Upvote 0
Aahh you are looking for 15, not 1+5. Sorry. I don't know. Maybe you should wait for other replies.
Right. The numbers that are together have to be treated as a single value. Thanks for the help though!
 
Upvote 0
Thank you for the formula. My version of Excel (2016) doesn't seem to include the SEQUENCE function. So, I'm getting an error.
You should update your profile to reflect the version of Excel you are using.
 
Upvote 0
Try this in your copy of XL365...
Excel Formula:
=SUM(0+TEXTSPLIT(TRIM(CONCAT(IFERROR(0+MID(A1,SEQUENCE(LEN(A1)),1)," ")))," "))
 
Upvote 1
Thank you for the formula. My version of Excel (2016) doesn't seem to include the SEQUENCE function. So, I'm getting an error.
Your profile is showing you have XL365, XL2021 and XL2007... where did the XL2016 come from????
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,206
Members
452,618
Latest member
Tam84

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