Count How Many Times Comma Separated Letters In a String

L

Legacy 143009

Guest
I have a list of letters in a single cell in form of comma separated values. (i.e a,b,c,d)
What I want to check is, how many times any of these letters appear in a cell value. (ie. "Carla" has 2 'a's and 1 'c', so desired result should be 3).

Thanks for help!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
For Excel 2019, you could try:

Excel Formula:
=SUMPRODUCT(LEN(B1)-LEN(SUBSTITUTE(LOWER(B1),FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s"),)))

Where A1 holds the comma-seperated values and B1 is "Carla". Note that I assume lowercase letters thus we need to include LOWER() since SUBSTITUTE() is case-sensitive.

For ms365 users this could be written like:

Excel Formula:
=SUM(LEN(B1)-LEN(SUBSTITUTE(LOWER(B1),TEXTSPLIT(A1,","),)))
 
Upvote 0
Solution
For Excel 2019, you could try:

Excel Formula:
=SUMPRODUCT(LEN(B1)-LEN(SUBSTITUTE(LOWER(B1),FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s"),)))

Where A1 holds the comma-seperated values and B1 is "Carla". Note that I assume lowercase letters thus we need to include LOWER() since SUBSTITUTE() is case-sensitive.

For ms365 users this could be written like:

Excel Formula:
=SUM(LEN(B1)-LEN(SUBSTITUTE(LOWER(B1),TEXTSPLIT(A1,","),)))
OK,

SUM() function did the trick. I don't know how I didn't come with it :) Thanks a lot (y)
 
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top