Search code examples
regexgoogle-sheetsgoogle-sheets-formulaarray-formulassumproduct

Convert text to numeral text


I have a google spreadsheet that I am using as a quiz. The quiz takers select an option from a data validation drop down.

The cell below strips all but the first character =left(A2,1) which is a numeral value. Further below in the sheet is a cell that sums certain cells, For instance,

=Sum(A3,D3)

Example

For some reason, the sum function does not recognize the cell as a purely numeral value, even with changing the format to number. Any ideas?


Solution

  • you can use SUMPRODUCT instead of SUM which is able to recognize numeric values even if they are disguised as a text string:

    =SUMPRODUCT(A3:D3)
    

    another way would be use regex like:

    =ARRAYFORMULA(REGEXEXTRAXT(A3:D3, "(\d+)-")*1)