I would like to count all special characters (!%_*?+-,) in a cell.
For example:
With this formula =LEN(D2)-LEN(SUBSTITUTE(D2;\"!\";\"\"))
i
Using formulas only, not VBA, this is possible with the following two approaches:
Consider the text in A1
:
First approach:
Multiple nested SUBSTITUTE
:
=LEN(A1)-LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,",",""),"-",""),"+",""),"?",""),"*",""),"_",""),"%",""),"!",""))
Second approach:
Using SUMPRDUKT
for getting the MID
function in array context to get each single charachter of the string in A1
compared with each single special character:
=SUMPRODUCT(--(MID(A1,ROW($1:$1000),1)={"!","%","_","*","?","+","-",","}))