Count number of values in a cell unless blank

后端 未结 2 733
北恋
北恋 2021-01-23 09:57

I have a cell that uses a drop-down list that allows for multiple selections. How do I count the number of selections?

I used this: =LEN(A2)-LEN(SUBSTITUTE(A2,\",\",\"\"

2条回答
  •  耶瑟儿~
    2021-01-23 10:15

    If you want your formula to ignore consecutive comma's:

    =LEN(A2)-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,",,",","),",,",","),",",""))+1
    

    It's doubled-up to account for odd numbers of sets of commas.


    or to totally jack-all @Jeeped's suggestions, if the values in your drop down do not have spaces, a better way might be:

    =LEN(A2)-LEN(TRIM(SUBSTITUTE(SUBSTITUTE(A2,","," ")," ","")))+1
    

提交回复
热议问题