Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default Count Instances of a Specific Character

here's what I am trying to do - I am trying to split up a cell based
on it's contents. While the data is in the same order in the column
and it is delimited by a space, it doesn't work to delimit it by
spaces or by number of charatcers.

The problem is that between the delimiters there may be 1 or 2 words -
separated by a comma and the data may be of variable length.

Is there a way to Count the Instances of a Specific Character - for
example, is there a function to count the number of spaces in this
sentence? Or the number of x's?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Count Instances of a Specific Character

=len(a1)-len(substitute(a1,"x",""))
will count the number of lowercase x's in A1.
(=substitute() is case sensitive)

If you wanted the total number of x's (upper or lower):
=len(a1)-len(substitute(upper(a1),"X","")
or
=len(a1)-len(substitute(upper(a1),upper("x"),"")

(I'm always afraid that I'll forget to make that "X" upper case, so I like to
use the =upper() function to remind me.)

And if you have lots of spaces that you want to get rid of:
=trim(a1)
will remove leading, trailing and change multiple internal spaces to a single
space:

---qwer----asdf-qwer---qwer------- (- = space)
will become
qwer asdf qwer qwer
after =trim()



Commish wrote:

here's what I am trying to do - I am trying to split up a cell based
on it's contents. While the data is in the same order in the column
and it is delimited by a space, it doesn't work to delimit it by
spaces or by number of charatcers.

The problem is that between the delimiters there may be 1 or 2 words -
separated by a comma and the data may be of variable length.

Is there a way to Count the Instances of a Specific Character - for
example, is there a function to count the number of spaces in this
sentence? Or the number of x's?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default Count Instances of a Specific Character

On Mon, 10 Aug 2009 14:45:52 -0700 (PDT), Commish
wrote:

here's what I am trying to do - I am trying to split up a cell based
on it's contents. While the data is in the same order in the column
and it is delimited by a space, it doesn't work to delimit it by
spaces or by number of charatcers.

The problem is that between the delimiters there may be 1 or 2 words -
separated by a comma and the data may be of variable length.

Is there a way to Count the Instances of a Specific Character - for
example, is there a function to count the number of spaces in this
sentence? Or the number of x's?



Try this formula:

=SUMPRODUCT(--(MID(A1,ROW(OFFSET($A$1,,,LEN(A1))),1)="x"))

The result should be the number of x's in cell A1.

Hope this helps / Lars-Åke


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 the times a specific character appears in a cell [email protected] Excel Worksheet Functions 3 December 18th 08 11:36 AM
How do I count occurances of a specific character in a range? Viridel Excel Worksheet Functions 1 January 18th 08 01:55 AM
counting instances of specific times in fields with date and time Rob Odum Excel Worksheet Functions 2 April 13th 06 04:06 PM
Count Instances Ken Excel Discussion (Misc queries) 2 April 2nd 05 12:41 AM
HOW to COUNT THE FREQUENCY of specific CHARACTER WITHIN a CELL? Shooting Star Excel Discussion (Misc queries) 1 February 22nd 05 10:15 PM


All times are GMT +1. The time now is 01:00 AM.

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

About Us

"It's about Microsoft Excel"