简体   繁体   中英

Count number of pieces data is split to by a certain delimiter

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.

What formula should I use is the column B?

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM