This formula counts the number of Bs (uppercase only) in the string in cell A1:
=LEN(A1)-LEN(SUBSTITUTE(A1,”B”,””))
This formula uses the SUBSTITUTE function to create a new string (in memory) that has all the Bs
removed. Then the length of this string is subtracted from the length of the original string. The
result reveals the number of Bs in the original string.
The following formula is a bit more versatile. It counts the number of Bs (both upper- and lower-
case) in the string in cell A1.
=LEN(A1)-LEN(SUBSTITUTE(SUBSTITUTE(A1,”B”,””),”b”,””))
=LEN(A1)-LEN(SUBSTITUTE(A1,”B”,””))
This formula uses the SUBSTITUTE function to create a new string (in memory) that has all the Bs
removed. Then the length of this string is subtracted from the length of the original string. The
result reveals the number of Bs in the original string.
The following formula is a bit more versatile. It counts the number of Bs (both upper- and lower-
case) in the string in cell A1.
=LEN(A1)-LEN(SUBSTITUTE(SUBSTITUTE(A1,”B”,””),”b”,””))
No comments:
Post a Comment