excel help - counti...
 

Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop

[Closed] excel help - counting numbers of letters?

8 Posts
5 Users
0 Reactions
56 Views
Posts: 12499
Full Member
Topic starter
 

100 names consisting of a bunch of different letters, as you'd expect, how do I count the number of a's in the whole lot, number of b's number of c's? Without getting horribly manual about the whole thing?

Any help gratefully appreciated!

Thanks,

Ed


 
Posted : 11/09/2012 11:34 pm
 poly
Posts: 8747
Free Member
 

I'm not aware of an easy formula to do that. Its not something people would normally use excel for, so its unlikely to be trivial... ...assuming you don't want to build a macro (or even better create a programme outside excel to do it) then.

Assuming the name are in Column A (starting in row 1).
Insert a row above the names and but 1 in B1, and drag across so you get 2, 3, 4, etc [you will need to as far over as your longest name]
Inset this formula in B1: =IF(LEN($A2)>=B1,RIGHT(LEFT($A2,B1),1),"")
Drag it across the columns. You should see Joe Bloggs appear as J o e B l o g g s
Drag down your 100 name.

Now you can use something like

=COUNTIF(B2:AZ101, "A")

NOTE this is NOT case sensitive (i.e.. a=A)
You can obviously populate the whole alphabet by adapting that formula.


 
Posted : 12/09/2012 12:30 am
 tron
Posts: 0
Free Member
 

Try searching for letter frequency rather than letter counting. It's not an overly uncommon thing to look - letter coding in qualitative analysis and obviously basic cryptography.


 
Posted : 12/09/2012 6:11 am
Posts: 36
Free Member
 

For a list of names in column A from A1 to A100

and

A CAPITALISED alphabetical list in column B starting with A in B1 to Z in B26

Then in C1 paste, and drag to C26:

=SUMPRODUCT(LEN($A$1:$A$100)-LEN(SUBSTITUTE(UPPER($A$1:$A$100),B1,"")))

What this does is turns all the text in each cell of an array of cells (A1:A100) into upper case (UPPER), it then replaces all incidents of the Letter you are searching for (In the above formula that would be A referenced by B1) with a blank (""). It then compares the length of the original string (LEN) with the length of that string without the searched letter in and tots it up (SUMPRODUCT).


 
Posted : 12/09/2012 6:28 am
Posts: 4191
Free Member
 

Slightly but not massively manual, do a search and replace for "a" replace with "a" and it will tell you how many times it was replaced.


 
Posted : 12/09/2012 6:57 am
 poly
Posts: 8747
Free Member
 

Stoners method is rather elegant. I'd go with that.


 
Posted : 12/09/2012 7:21 am
Posts: 12499
Full Member
Topic starter
 

Thanks all!

I had a feeling you'd pop up, Stoner. Thank you very much.


 
Posted : 12/09/2012 8:05 am
Posts: 36
Free Member
 

prego.


 
Posted : 12/09/2012 8:26 am
Posts: 12499
Full Member
Topic starter
 

Worked a treat, cheers again. Her in charge can get ordering now.

And because I quite liked Greybeard's lateral thinking, I used that to check a couple.


 
Posted : 12/09/2012 8:36 am