Forum Discussion

ronakbohra1994's avatar
ronakbohra1994
Copper Contributor
Jun 10, 2020

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 that by using the formula?

 

Thanks

2 Replies

  • peteryac60's avatar
    peteryac60
    Iron Contributor

    ronakbohra1994 

     

    Attached is a simple example - you extract the number (using MID function) and convert to number (using NUMBERVALUE function). Then you can sum them.

     

    Of course if you have many different types of texts (e.g. TOMATO 20) you will need to adjust the formula e.g. use FIND/SEARCH functions to identify the space before the number , then use MID/NUMBERVALUE as above.

     

    Hope this is of some help.

     

    Peter

     

Resources