Count the number of specific characters in a cell

JayReddy

New Member
Joined
Sep 9, 2014
Messages
9
Good Day,

I am trying to write a formula to count the number of specific characters in a cell. This has proved successful to a degree utilising a LEN formula that I have listed below:

=LEN(A1)+(1)-LEN(SUBSTITUTE(A1,"+",""))

With the above formula I am counting how many times the plus (+) symbol appears in the cells in column A and then adding the value of 1 to the total and this is calculating correctly.

The below example shows the correct count of characters in column A utilising the above formula:


Column A - DataCount
1+2+2.4+2+65
1+2+3+44
1+4+7+6.5+7.86+36

<tbody>
</tbody>
Now I want to expand the formula to include an additional character. This would be the minus (-) symbol.

I need the formula to count how many times either the plus (+) or minus (-) symbol appear in a cell in column A and add these two counts together and then add an additional value of 1.

The below example shows the desired total count of characters in column A:


Column A - DataCount
5+4+5+3.0-65
8-3+6-3-15
9+4+2-2-2-16

<tbody>
</tbody>

Is there any way to expand my existing formula to count more than one character (i.e. the plus (+) and minus (-) symbols together)?

Any assistance in this regard would be greatly appreciated.

Best Regards,
Jay




 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Re: How to count the number of specific characters in a cell

You can nest multiple substitutes together. Try:


Excel 2013/2016
ABC
1Column A - DataCount (Desired)Count (Formula)
25+4+5+3.0-655
38-3+6-3-155
49+4+2-2-2-166
Sheet1
Cell Formulas
RangeFormula
C2=LEN(A2)-LEN(SUBSTITUTE(SUBSTITUTE(A2,"+",""),"-",""))+1
 
Upvote 0
Re: How to count the number of specific characters in a cell

Hi MrKowz,

Thanks a lot for your help - this works perfectly :cool:

I have an additional query for a similar formula that I hope you can also help with please ..... is it possible to count the number of individual entries in a cell when calculating a sum?

For example: +2+2+4-1 = a total of 7 but is 4 separate entries.

Using a COUNT formula I can only seem to get Excel to count these entries as 1 singular entry.

I am using a spreadsheet to calculate both the number of individual adjustments made in an accounting period and their total value. Each +/- in an individual cell represents 1 adjustmentand I need to find a formula to both calculate and report this accurately.

Best Regards,
Jay
 
Upvote 0
Re: How to count the number of specific characters in a cell

I'm not sure I follow - can you please give me some extra examples, the desired output, and your thought process in how you arrived to the output?
 
Upvote 0
Re: How to count the number of specific characters in a cell

Good morning
I am having an issue with counting characters that i hope someone might be able to resolve for me
I am trying to count the number of times a full stop appears before a part name i.e

Item Name
. Part 11
Part 2
.. Part 32
… Part 43
Part 5
Part 6
. Part 71
.. Part 82
….. Part 95

<colgroup><col><col></colgroup><tbody>
</tbody>

The issue i am having using all the available formulas is that none of them seem to be able to deal with more than 2 full stops, and i am getting the following result
Using the formula

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

Item Name
. Part 11
Part 20
.. Part 32
… Part 40
Part 50
Part 60
. Part 71
.. Part 82
….. Part 92

<colgroup><col><col></colgroup><tbody>
</tbody>


Any help on this is gratefully received
 
Upvote 0
Re: How to count the number of specific characters in a cell

Your problem is that ... is not 3 periods but an ellipses.
There's probably a cleaner way but try
=LEN(A5)-LEN(SUBSTITUTE(A5,".",""))+((LEN(A5)-LEN(SUBSTITUTE(A5,CHAR(133),"")))*3)
 
Upvote 0
Re: How to count the number of specific characters in a cell

Fluff

Thanks very much that works a treat
 
Upvote 0
Re: How to count the number of specific characters in a cell

You're welcome
 
Upvote 0
Re: How to count the number of specific characters in a cell

Hi guys. Although the above solution worked perfectly i have an amendment to it and am wondering if you might have a solution
If i have the following item where there are more than 1 full stop within the part name, would it be possible to just pick up the leading full stops and not the ones within the part name ? (examples below)

. Bonnet
.. Cover piece 1 @ 22.5mm
... Cover piece with attachment 22.5cm x 12.75cm

Apologies for changing the requirement and thanks for the initial solution
 
Upvote 0
Re: How to count the number of specific characters in a cell

How about
=7-LEN(SUBSTITUTE(LEFT(E2,7),".",""))+((7-LEN(SUBSTITUTE(LEFT(E2,7),CHAR(133),"")))*3)
change the 7s to a number that is less then the shortest string length, but more than the number of . you are likely to get.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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