Forum Discussion
ronakbohra1994
Jun 10, 2020Copper Contributor
How to sum the numbers in a text string?
Hi If I have a text string in a cell below: "Apple 5 (+) Apple 10 (+) Apple 25 (+) Apple 20 (-)" And I would like to return the result of the sum of the numbers 5+10+25-20 "20" How can I do th...
SergeiBaklan
Jun 10, 2020Diamond Contributor
As variant
=SUMPRODUCT(
FILTERXML("<r>"&SUBSTITUTE(SUBSTITUTE(A1,"Apple ","<a>"),"(","</a>")&"</r>","//a")*
FILTERXML("<r>"&SUBSTITUTE(SUBSTITUTE(A1,"(","<a>"),")","1</a>")&"</r>","//a")
)