excelexcel-formula

How to extract how many numbers are in a text cell


I have 2 columns. First column represent the range of rented nights of a room. Second column represent the total number of nights. The numbers can be between 1 and 31. How can I calculate automatically on the second column the count of nights ? Thanks for reading this !

enter image description here


Solution

  • Try using TEXTSPLIT() & COUNT()

    enter image description here


    =COUNT(--TEXTSPLIT(A2,{" ",","},,1))
    

    Or,

    Or in Google Sheets as it seems from the screenshot:

    enter image description here


    =COUNT(SPLIT(A2," ,"))
    

    Another way in Google-Sheets:

    enter image description here


    =COUNT(SPLIT(REGEXREPLACE(A2," |,","|"),"|"))