Count Characters Minus One

barim

Board Regular
Joined
Apr 19, 2006
Messages
176
I am using Len Function to count number of characters:

=LEN(A1)

Now, I have instances that I would like to count as one character and not 2. For example, instances like "DZ" or "LJ", if they exist anywhere in the word it should be counted as -1 to the total of characters. I can solve this with : =LEN(A1) -1, but I have to enter manually and it is a lot of manual work.
I have also tried this:

=IF("lj"|LEN(A1)-1|LEN(A1))

but it throws error.

Is there any way to accomplish this with formula?

Thanks.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Maybe:

=LEN(SUBSTITUTE(A1,"DZ","D"))

If case matters, then you may need to use UPPER. You can string multiple codes like this:

=LEN(SUBSTITUTE(SUBSTITUTE(A1,"DZ","*"),"LJ","*"))
 
Last edited:
Upvote 0
How about
=IF(OR(ISNUMBER(SEARCH("LJ",A2)),ISNUMBER(SEARCH("DZ",A2))),LEN(A2)-1,LEN(A2))
this is not case sensitive
 
Upvote 0
Thank you all for your replies. Fluff's formula works perfectly. For some reason Eric's formulas don't work at all, and total number has not changed. I like the idea to substitute instance of two characters and replace it with one and then make a count. Thank you again for your replies.
 
Upvote 0
It might be the upper case issue, you can try:

=LEN(SUBSTITUTE(SUBSTITUTE(UPPER(A1),"DZ","*"),"LJ","*"))
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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