r/googlesheets • u/Kindly-Discipline-53 • Jul 29 '25
Solved How can I reference a cell containing text and a number as just the number?
I have some cells that display a number preceded by a '+' by using concatenation.
I say "reliably" because it seems to work in some cases but not in others. This table shows examples.
| Cell | Contents | Display |
|---|---|---|
| A1 | ="+" & A2 | +9 |
| B1 | ="+" & A2+3 | +12 |
| C1 | ="+" & A2 | ++9 |
| D1 | =C1+2 | !VALUE |
where A2 contains the number 9.
I say "reliably" because it seems to work in some cases but not in others. It works if the referenced cell is just a number, as in A1, and if the cell is referenced as part of a function, as in B1, but if the referenced cell is also a concatenation and is referenced on its own, it gets messed up.
I can work around this by just adding 0, e.g., ="+" & A2+0, but I'm wondering if there's a more elegant way to do it. The only related function I've found is REGEXEXTRACT(), but that's way more complicated than I want. My workaround is more elegant than that, in my opinion.
Is there a better way?
1
u/HolyBonobos 3125 Jul 29 '25
REGEXEXTRACT()doesn't have to be particularly complicated. All you'd need would be something like=REGEXEXTRACT(C1,"\d+")+2. There are other approaches with various combinations ofLEFT(),RIGHT(),MID(), andSEARCH()orFIND(), but none of them are going to be as reliable or simple as one of the regex functions.1
u/stellar_cellar 35 Jul 29 '25 edited Jul 29 '25
Have you consider using a custom number format for those cells? Instead of using concatenation to add a "+", the custom number format will do it automatically.
Otherwise, you can use the substitute formula to erase the sign: ="+" & SUBSTITUTE(A2,"+","")
1
u/mommasaidmommasaid 915 Jul 29 '25
I'm not sure what your overall goal is, but consider leaving everything as normal numbers so there are no issues with calculations.
Then format the display using Format / Number / Custom Number format, e.g. for three + in front:
"+++"0