Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ken Ken is offline
external usenet poster
 
Posts: 590
Default Count occurences in string

This should be very simple, but I don't see how to do it without a macro:
How do you count the number of hyphens (for example) in a string?

abc-de-a32-ej2-wkjew-w should give 5
we2-232if should give 1
wekjf2 should give 0

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Count occurences in string

The below formula will do.

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

If this post helps click Yes
---------------
Jacob Skaria


"Ken" wrote:

This should be very simple, but I don't see how to do it without a macro:
How do you count the number of hyphens (for example) in a string?

abc-de-a32-ej2-wkjew-w should give 5
we2-232if should give 1
wekjf2 should give 0

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Count occurences in string

On Wed, 10 Jun 2009 11:55:02 -0700, Ken wrote:

This should be very simple, but I don't see how to do it without a macro:
How do you count the number of hyphens (for example) in a string?

abc-de-a32-ej2-wkjew-w should give 5
we2-232if should give 1
wekjf2 should give 0


=len(str)-len(substitute(str,"-","")

--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
Ken Ken is offline
external usenet poster
 
Posts: 590
Default Count occurences in string

Ah ... of course. Thank you both.

Ken

This should be very simple, but I don't see how to do it without a macro:
How do you count the number of hyphens (for example) in a string?

abc-de-a32-ej2-wkjew-w should give 5
we2-232if should give 1
wekjf2 should give 0


=len(str)-len(substitute(str,"-","")

--ron

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
SUMPRODUCT to calculate unique occurences of string in column of d WildWill Excel Discussion (Misc queries) 3 April 3rd 09 03:16 PM
Count Occurences Lmurraz Excel Discussion (Misc queries) 3 July 11th 07 02:46 PM
Count # of Occurences Sweepea Excel Discussion (Misc queries) 6 December 14th 06 02:27 AM
count number of occurences within a string Gabriel Excel Worksheet Functions 2 November 25th 04 04:17 PM
Count occurences between dates DJ Dusty Excel Worksheet Functions 3 November 11th 04 12:25 AM


All times are GMT +1. The time now is 02:46 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"