计数数据数据按特定分隔符分割

时间:2020-12-05 22:51:41

Data looks like this:

数据如下所示:

Aaa, Bbb, Ccc, Ddd, Eee, Fff
Aaa, Bbb, Ccc, Ddd, Eee
Aaa, Bbb, Ccc, Ddd
Aaa, Bbb, Ccc
Aaa, Bbb
Aaa

Data in rows is split by the ',' delimiter. I want to get the number of parts that each row is split to. Here is the figure:

行中的数据由“,”分隔符分隔。我想获得每行被拆分的部件数量。这是图:

计数数据数据按特定分隔符分割

So, in the 1st row the data is split to 6 parts by ',' delimiter. In the 2nd - 5 parts and so on.

因此,在第1行中,数据被','分隔符拆分为6个部分。在第2 - 5部分等。

What formula should I use is the column B?

我应该使用什么配方是B栏?

1 个解决方案

#1


7  

I'd use this formula:

我用这个公式:

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

In case you need 0, when the cell is empty (the above formula returns 1), use this:

如果你需要0,当单元格为空(上面的公式返回1)时,使用:

=IF(A1="",0,LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1)

#1


7  

I'd use this formula:

我用这个公式:

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

In case you need 0, when the cell is empty (the above formula returns 1), use this:

如果你需要0,当单元格为空(上面的公式返回1)时,使用:

=IF(A1="",0,LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1)