How to extract text values from a cell in google sheets and add them (without Google Apps Script)

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 have a google sheet which tracks various categories of values, and these categories get summed up. So, the final result is a number.

Sample data:
"E(12), P-6, TW=4, 5" => The key values are: 12+6+4+5, formula should return 27
"2E, 2P, 6TW, 2O" => The key values are: 2+2+6+2, formula should return 12

I'm able to do this with a custom function via GAS, but if there was a way to do it in a formula, using the built-in functions, my google sheet would run much faster. It contains thousands of instances of the custom function.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi, try this..
Excel Formula:
=SUM(ARRAYFORMULA(VALUE(REGEXEXTRACT("a"&SPLIT(A1,","),"(\d+)+"))))
 
Upvote 0
Solution
This is what Excel is missing….
 
Upvote 0
Hi, try this..
Excel Formula:
=SUM(ARRAYFORMULA(VALUE(REGEXEXTRACT("a"&SPLIT(A1,","),"(\d+)+"))))
That did it. I just added a conditional statement for cases where the cell is blank:
Excel Formula:
=IF(A1="","",SUM(ARRAYFORMULA(VALUE(REGEXEXTRACT("a"&SPLIT(A1,",")
[/QUOTE]

For extra points, it'd be great if this could be modified to take in a range and return the grand total, but this gets the job done. Thank you!
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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