Count letters in a string

pamaga

Board Regular
Joined
Jul 3, 2002
Messages
82
Hi all,
Sorry if this has been covered, but I have not found it in my searches so far.
How can I determine the number of times a specific letter appears in a given string?

Thanks in advance.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
On 2002-07-04 07:33, pamaga wrote:
Hi all,
Sorry if this has been covered, but I have not found it in my searches so far.
How can I determine the number of times a specific letter appears in a given string?

Thanks in advance.

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

where A1 houses a string and E1 the target letter to count.
 
Upvote 0
Are you trying to do this with a cell formula, or with VBA code?

Aladin,
Just saw your formula, very clever! I like it.

Steve

P.S. The formula is case-sensitive, but that can be modified, if desired.
This message was edited by stevebausch on 2002-07-04 08:06
 
Upvote 0
Very clever indeed, hey?... :)
In my version of Excel I had to change things a bit (also to accommodate upper- and lowercase variants), but once the concept was shown, everything is easy.
Conceptually simple, elegant, and very smart... And enough praise now!
 
Upvote 0
How can I adjust this formula to count A or a as the same letter.

Example And Atom was = 3 A's
 
Upvote 0

Forum statistics

Threads
1,213,529
Messages
6,114,155
Members
448,554
Latest member
Gleisner2

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