-1

Is there a way to take a text in a cell that says 5*5 and to parse to make the result 25... using QUERY function or any of the other built-in functions...?

player0
  • 124,011
  • 12
  • 67
  • 124
CodeCamper
  • 6,609
  • 6
  • 44
  • 94

3 Answers3

2

it would be like this:

=QUERY(SPLIT(B19, "*"), "select Col1*Col2 label Col1*Col2''")

0

player0
  • 124,011
  • 12
  • 67
  • 124
1

No. But if you have all such Mathematical expressions in a defined range(say,A5:A7), then you can use Find and Replace

FIND:

^    

REPLACE:

=

Range:

Sheet1!A5:A7

Checkmark "Search using regular expressions". Click Replace all. Otherwise you'll need scripts.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
1

IF you are just looking to parse simple mathematical expressions (+,-,x,/), then it can be done, but not in a single formula.

First, you can split the text based on your math operator, which will provide the numbers. Then you can use regexextract to output the math operator, then use a nested if to perform the needed math operation on the numbers, based upon that operator. You can hide the intermediate columns to put the answer next to the original.


image

Note that if you need to do more complex operations or operations on more than two numbers, this will not work.

Ron Kloberdanz
  • 442
  • 3
  • 8
  • This seems to be the only solution I could come with. Although I like how you actually used the multiply and add functions to make it cleaner looking. Like you said the limitation is to simple functions or this could really get out of hand... but in my application it was just a simple calculation. – CodeCamper Jul 27 '18 at 17:37