计算单元格中值的数量,除非空白 [英] Count number of values in a cell unless blank

查看:26
本文介绍了计算单元格中值的数量,除非空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用下拉列表的单元格,允许进行多项选择.我如何计算选择的数量?

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

我用过这个:=LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1

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

但这不考虑空白或无选择.如果没有选择,我如何也显示 0?

But this doesn't account for blank or no selection. How can I display 0 as well if there is no selection?

推荐答案

如果您的选择没有空格,则用逗号代替空格,修剪结果,然后用逗号计算上述空格.

If your selections do not have spaces then substitute commas for spaces, trim the result then count for spaces as above with commas.

=LEN(trim(SUBSTITUTE(A2,","," ")))-LEN(SUBSTITUTE(trim(SUBSTITUTE(A2,","," "))," ",""))+sign(len(a2))

这篇关于计算单元格中值的数量,除非空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆