Formula to count the characters in a cell, but exclude certain characters (plural)

Thistles

New Member
Joined
Aug 30, 2017
Messages
2
I'm learning as I go with Excel, and can't get my head around how to write this formula (if it is even possible).

I want to count the characters in a cell, but exclude certain characters (plural). E.g. coding and spaces. I know how to count the characters and exclude only spaces:

=LEN(SUBSTITUTE(A2," ",""))

I want to add to this formula so that it counts the characters in a cell, excluding not just spaces but other characters. For the purposes of this example, let's say I want to exclude both the letters x and y from the character count.

I tried various iterations, all of which threw up errors, then this one didn't but it doesn't work (gives me the wrong count):

=LEN(SUBSTITUTE(A2,"x",""))&LEN(SUBSTITUTE(A2,"y",""))

Is there a way to do it?

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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