Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default counting occurances of a char. within a text string/cell

Can anyone recommend a easy method for programmatically determining the
number of times a character occurs within a single cell (e.g., the character
"*" occurs 5 times in text "A*B*C*D*E*F"). Thanks,

Justin


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default counting occurances of a char. within a text string/cell

From a previous post...


Public Function GetCharCount(vString As String, CheckChar As String) as
Integer
Count=0
For n=1 to len(vstring)
If mid(vstring,n,1)=CheckChar then Count = Count + 1
Next
GetCharCount=Count
End Function


--
Regards,


Bill Lunney
www.billlunney.com

"Justin Ater" wrote in message
...
Can anyone recommend a easy method for programmatically determining the
number of times a character occurs within a single cell (e.g., the

character
"*" occurs 5 times in text "A*B*C*D*E*F"). Thanks,

Justin




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default counting occurances of a char. within a text string/cell

Justin,

Try something like

NumChars = Len(S) - Len(Replace(S, "*", ""))

where S is your string.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Justin Ater" wrote in message
...
Can anyone recommend a easy method for programmatically

determining the
number of times a character occurs within a single cell (e.g.,

the character
"*" occurs 5 times in text "A*B*C*D*E*F"). Thanks,

Justin




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
Counting Text Occurances - HELP PLEASE Beauty Girl Excel Worksheet Functions 1 January 13th 10 12:13 AM
How can I find a value from one cell in a char string in another? tiredazdaddy Excel Worksheet Functions 2 November 20th 08 05:40 PM
Counting # of occurances of words in text Mike G Excel Worksheet Functions 11 May 10th 07 12:50 AM
substituting two text occurances in same cell. Hassan Alameh Excel Worksheet Functions 4 March 9th 05 01:50 PM
Counting multiple occurances of a specific string BaseballFan Excel Worksheet Functions 1 February 26th 05 08:34 PM


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