Within one cell, I would like the value of the cell to be treated differently from the text inside that cell. For example, I would like the cell to display "$148 (123 euros)", but the value to be treated as 148
when I am summing that cell and another.
Google Sheets – Value in Cell Different from Text
google sheets
Related Topic
- Google Sheets – How to Sum Cells Until a Specific Value is Matched
- Google-sheets – Help with a “=QUERY(IMPORTRANGE(…” formula in Google Sheets
- Google Sheets – Multiply Cell Value on Edit
- Google-sheets – Rich text formatting in a Google Sheets cell
- Google Sheets – How to Include Text from a Cell within a COUNTIF Function
- Google-sheets – Use Text in cell as formula in Google Sheets
- Google-sheets – How to extract specific value from a single cell on Google Sheets
Best Answer
Given your example —
"$148 (123 euros)"
— you won't simply be able to refer to the cell when trying to do math with it.Let's say that your above string is in A2 and you want to divide the USD amount by 2 in cell B2. In cell B2, you'd use something like this:
=REGEXEXTRACT(A2,"\d+")/2
The
REGEXEXTRACT
will extract the first group of digits it finds, on which math can now operate.Keep in mind that if you only want to extract the number without any further math, you'll need to wrap the
REGEXEXTRACT
inVALUE
:=VALUE(REGEXEXTRACT(A2,"\d+"))
This is because
REGEXEXTRACT
extracts strings. When you apply further math operations, Sheets automatically knows you want to treat the extracted portion as a number. But if no math is applied, the extraction remains a string. SoVALUE
converts it to a number. In lieu of this, you could also just apply the math of*1
:=REGEXEXTRACT(A2,"\d+")*1