PC Review


Reply
Thread Tools Rate Thread

count number of times a particular letter appears in a cell

 
 
fallowfz
Guest
Posts: n/a
 
      24th Nov 2008
Is there a function which will return the number of times, for
example, the letter "E" appears in a cell containing a mix of text,
numbers, and other characters, e.g. (), :, etc?


Thanks!
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      24th Nov 2008
=len(a1)-len(substitute(upper(a1),"E",""))
will count the number of lower or upper case E's in A1.

=len(a1)-len(substitute(a1,"E",""))
will count the number of upper case E's in A1.

(=substitute() is case sensitive)


fallowfz wrote:
>
> Is there a function which will return the number of times, for
> example, the letter "E" appears in a cell containing a mix of text,
> numbers, and other characters, e.g. (), :, etc?
>
> Thanks!


--

Dave Peterson
 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      24th Nov 2008
You can do it with a formula:

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

This is case sensitive. For case insensitive, use

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

In code, use

Dim S As String
Dim N As Long
S = Range("A1").Text
N = Len(S) - Len(Replace(S, "e", vbNullString))
Debug.Print N

This is case sensitive. For case insensitive, use

Dim S As String
Dim N As Long
S = Range("A1").Text
N = Len(S) - Len(Replace(UCase(S), "E", vbNullString))
Debug.Print N

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Mon, 24 Nov 2008 10:51:43 -0800 (PST), fallowfz
<(E-Mail Removed)> wrote:

>Is there a function which will return the number of times, for
>example, the letter "E" appears in a cell containing a mix of text,
>numbers, and other characters, e.g. (), :, etc?
>
>
>Thanks!

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      24th Nov 2008
Hi,

Try this case sensitive idea

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

Mike

"fallowfz" wrote:

> Is there a function which will return the number of times, for
> example, the letter "E" appears in a cell containing a mix of text,
> numbers, and other characters, e.g. (), :, etc?
>
>
> Thanks!
>

 
Reply With Quote
 
fallowfz
Guest
Posts: n/a
 
      24th Nov 2008
On Nov 24, 2:12*pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> Hi,
>
> Try this case sensitive idea
>
> =LEN(A1)-LEN(SUBSTITUTE(A1,"E",""))
>
> Mike
>
>
>
> "fallowfz" wrote:
> > Is there a function which will return the number of times, for
> > example, the letter "E" appears in a cell containing a mix of text,
> > numbers, and other characters, e.g. (), :, etc?

>
> > Thanks!- Hide quoted text -

>
> - Show quoted text -


WOW...thanks for the quick responses. All of them work great!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel= can I count how many times letter a appears in 1 cell? =?Utf-8?B?SmFjayBE?= Microsoft Excel Worksheet Functions 6 1st Nov 2007 03:18 PM
I WANT TO COUNT HOW MANY TIMES A CERTAIN LETTER APPEARS IN A ROW =?Utf-8?B?c3ByaW5nMDIyMzc3?= Microsoft Excel Worksheet Functions 13 16th Feb 2007 08:39 AM
How do I count the number of times a value appears? =?Utf-8?B?Q2hyaXN0aW5l?= Microsoft Excel Worksheet Functions 2 8th Feb 2007 09:38 PM
How do I count the number of times a letter is used in a cell? =?Utf-8?B?anNyYXdsaW5ncw==?= Microsoft Excel Misc 5 28th Jun 2006 02:02 AM
Count Number of Times Something appears =?Utf-8?B?TWFyayBC?= Microsoft Excel Worksheet Functions 5 29th Nov 2005 08:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 PM.