Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
jsrawlings
 
Posts: n/a
Default How do I count the number of times a letter is used in a cell?

I want to be able to count the number of times a letter is used in a cell.
For example, if cell A2 contains the string "radar" I want to be able to
have excel return the number of times the letter "a" is used (2).
  #2   Report Post  
Posted to microsoft.public.excel.misc
Marcelo
 
Posts: n/a
Default How do I count the number of times a letter is used in a cell?

Hi,

use this code:

Press ALT+F11 copy and paste there
use =countchar("a";a1)

__________________________________________
Function CountChar(MyChar, Mystring)
Dim counter As Integer

CountChar = 0

For counter = 1 To Len(Mystring)
If Mid(Mystring, counter, 1) = MyChar Then CountChar = CountChar + 1
Next counter

End Function

_____________________________________

hope this helps
regards from Brazil
Marcelo





"jsrawlings" escreveu:

I want to be able to count the number of times a letter is used in a cell.
For example, if cell A2 contains the string "radar" I want to be able to
have excel return the number of times the letter "a" is used (2).

  #3   Report Post  
Posted to microsoft.public.excel.misc
Bearacade
 
Posts: n/a
Default How do I count the number of times a letter is used in a cell?


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


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=556259

  #4   Report Post  
Posted to microsoft.public.excel.misc
Elkar
 
Posts: n/a
Default How do I count the number of times a letter is used in a cell?

Since SUBSTITUTE is case sensitive, you might also consider:

=LEN(D23)-LEN(SUBSTITUTE(SUBSTITUTE(D23,"A",""),"a",""))

This will count both "A" and "a"

HTH,
Elkar


"Bearacade" wrote:


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


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=556259


  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default How do I count the number of times a letter is used in a cell?

Or just:

=LEN(D23)-LEN(SUBSTITUTE(Upper(D23),"A",""))



Elkar wrote:

Since SUBSTITUTE is case sensitive, you might also consider:

=LEN(D23)-LEN(SUBSTITUTE(SUBSTITUTE(D23,"A",""),"a",""))

This will count both "A" and "a"

HTH,
Elkar

"Bearacade" wrote:


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


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=556259



--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
Ragdyer
 
Posts: n/a
Default How do I count the number of times a letter is used in a cell?

So will this:

=LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),"A",""))

--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Elkar" wrote in message
...
Since SUBSTITUTE is case sensitive, you might also consider:

=LEN(D23)-LEN(SUBSTITUTE(SUBSTITUTE(D23,"A",""),"a",""))

This will count both "A" and "a"

HTH,
Elkar


"Bearacade" wrote:


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


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile:
http://www.excelforum.com/member.php...o&userid=35016
View this thread:
http://www.excelforum.com/showthread...hreadid=556259



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count number of uniques starting with a given letter? MeatLightning Excel Discussion (Misc queries) 1 April 26th 06 10:32 PM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
count the number of times the same number shown Noemi Excel Discussion (Misc queries) 1 September 22nd 05 04:00 AM
Count number of cells that contain a certain letter - Case Sensitive elite Excel Discussion (Misc queries) 4 September 20th 05 01:41 PM
How do I get a letter in one cell ito equal a number in anotherl.. Dave Cadey Excel Discussion (Misc queries) 4 February 25th 05 02:37 PM


All times are GMT +1. The time now is 09:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"