Count the number of time a character appears in a string

AndyD

Active Member
Joined
Nov 14, 2002
Messages
449
Hi can supply me with formula to count the number of time a character appears in a string

eg if cell A1 contains "Hello there my friend"...what is formula to count number of e's for example, thanks
Andy
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try:

=LEN(A1)-LEN(SUBSTITUTE(A1,"e",""))

where A1 contains your text.

Edit: Must press Refresh more often to avoid echoes. :wink:
 
Upvote 0
sorry i think i picked a really bad example of "e"....should've come out with what i actually wanted (silly me!)

i need to count number of dots in a string...this formula doesnt work for dots
 
Upvote 0
How about if you want to count the number of times a word is in a text string, like this

This is a test to count the number of times test is in this cell, this is for testing only
using =LEN(A1)-LEN(SUBSTITUTE(A1,"test","")) I get 12, should be 2, can this be done?
 
Upvote 0
using the same logic
=(LEN(A1)-LEN(SUBSTITUTE(A1," test ","")))/LEN(" test ")

note the spaces
 
Upvote 0
Thanks for the replys

andrew, yours stills counts testing

IML, that works for the text I gave, tried it with another test at the end and it did not find it, put another word after it and it worked then, so it want find the word if it is the last word in the string, can this be fixed??
 
Upvote 0
AC said:
Thanks for the replys

andrew, yours stills counts testing

IML, that works for the text I gave, tried it with another test at the end and it did not find it, put another word after it and it worked then, so it want find the word if it is the last word in the string, can this be fixed??

=(LEN(" "&A1&" ")-LEN(SUBSTITUTE(" "&A1&" "," test ","")))/LEN(" test ")
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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