A client has an Excel file that needs to have some names scrubbed. In particular, we're trying to isolate suffixes on names (e.g., Jr., Sr., III, etc.) Names are ALWAYS formatted LastName, FirstName, Suffix
in the cell, and I am trying to count the number of commas in a cell. If the cell has more than one comma in it, I can identify that cell as having a name suffix.
However, all of the COUNT
functions in Excel count instances of CELLS, not characters within cells. Is there a function that counts occurrences of specific characters in a cell and returns that count?
You can get the number of characters in the cell and then compare that to the number of characters in the cell if you substituted out all the commas with empty spaces:
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))
This is also a neat way to get word counts in excel by counting the number of spaces.
There may not be much point in counting commas because if you know there will always be two at most you might jump to:
=IFERROR(REPLACE(A1,FIND(",",A1,FIND(" ",A1)+1),99,""),A1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With