Search code examples
excelcountnumbers

Count number of numbers in a single cell


I want to count the number of numbers in a single cell.

Example:

In cell A1, I have the following addition:

=12+45+23+51+10 which totals (and shows) 141.

In cell B1, I would like the see how many numbers have been added together, which means that there should be 5 (12 is a number, 45 another one, etc... and all together, there are 5 numbers in cell A1).

I know it seems to be a ridiculous question, but I scanned all the platforms for this issue and did not find any suitable solution. Tried all the LEN and LEN SUBSTITUTE alternatives out there, but somehow it does not work.

Thank you upfront for your help. Optimal solution would be a excel formula, alternatively VBA would also work.


Solution

  • Excel 2013 has a new function Formulatext() which returns the, well, formula text. Using that the Len() and Substitute() approach works.

    =LEN(FORMULATEXT(A1))-LEN(SUBSTITUTE(FORMULATEXT(A1),"+",""))+1
    

    enter image description here