EXCEL计算单元格内某字符串的个数

标签:
excel计数单元格内lencountif |
分类: 其他软件及电子产品 |
(LEN(A1)-LEN(SUBSTITUTE(A1,"B","")))/n
A1是要计数的单元格名称,B是要计算的字符串,n是要计数的字符串的长度。这一串看似复杂,实则不然。len是用来计算字符的数量,比如单元格内有如下这些内容,
SUBSTITUTE(A1,"B","")的意思是说在A1这个单元格内,把所有等于B的字符删除,也就是后面""的作用。比如:
上例中,在C1单元格内用“=SUBSTITUTE(A1,"exclusive licensing agreement","")”,exclusive licensing agreement这个字符串就会被删除。
http://s3/mw690/002dDHI1gy6HxKhfusW12&690
用len(SUBSTITUTE(A1,"exclusive licensing agreement","")是计算替换后还剩多少字符串,
=LEN(A1)-LEN(SUBSTITUTE(A1,"exclusive licensing agreement",""))是计算相差多少字符串数量。
该例中,exclusive licensing agreement是29个字符串,最后把命令修改成
=(LEN(A1)-LEN(SUBSTITUTE(A1,"exclusive licensing agreement","")))/29
就可计算出A1这个单元格内原字符串的数量。
http://s1/mw690/002dDHI1gy6HxKwqFckd0&690