Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Haw to count ";" in a string

Hi experts
Haw do i count number of ; in my string z
im using this :

z = "bla;bla;bla;bla"
x = Len(z) - Len(Application.WorksheetFunction.Substitute(z, ";", ""))

is there a VBA command for this or is my way the only way ?

tks. in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Haw to count ";" in a string

z = "bla;bla;bla;bla"
MsgBox Len(z) - Len(Replace(z, ";", ""))

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


"excelent" wrote:

Hi experts
Haw do i count number of ; in my string z
im using this :

z = "bla;bla;bla;bla"
x = Len(z) - Len(Application.WorksheetFunction.Substitute(z, ";", ""))

is there a VBA command for this or is my way the only way ?

tks. in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Haw to count ";" in a string

oh ok but thats fine too

tanks alot Jacob

"Jacob Skaria" skrev:

z = "bla;bla;bla;bla"
MsgBox Len(z) - Len(Replace(z, ";", ""))

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


"excelent" wrote:

Hi experts
Haw do i count number of ; in my string z
im using this :

z = "bla;bla;bla;bla"
x = Len(z) - Len(Application.WorksheetFunction.Substitute(z, ";", ""))

is there a VBA command for this or is my way the only way ?

tks. in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Haw to count ";" in a string

On Tue, 27 Oct 2009 10:48:01 -0700, excelent
wrote:

Hi experts
Haw do i count number of ; in my string z
im using this :

z = "bla;bla;bla;bla"
x = Len(z) - Len(Application.WorksheetFunction.Substitute(z, ";", ""))

is there a VBA command for this or is my way the only way ?

tks. in advance


I don't know if this is any "better", but it is shorter:

UBound(Split(z, ";"))
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Haw to count ";" in a string

Haw do i count number of ; in my string z
im using this :

z = "bla;bla;bla;bla"
x = Len(z) - Len(Application.WorksheetFunction.Substitute(z, ";", ""))

is there a VBA command for this or is my way the only way ?

tks. in advance


I don't know if this is any "better", but it is shorter:

UBound(Split(z, ";"))


The Len method is more efficient than the Split method, but that would only
factor in if this code was being executed in a very large loop where the
time differences would accumulate. I tend to use this Split method for these
kinds of things as long as I am not involved in a large loop.

--
Rick (MVP - Excel)

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
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string Raja Mahendiran S Excel Worksheet Functions 6 May 12th 10 09:10 PM
Create Pivot Table Data with Column "Sum" rather than "count" defa Johnny_99[_2_] Excel Discussion (Misc queries) 2 January 2nd 10 03:25 PM
Converting "uppercase" string data to "lower case" in CSV file [email protected] Excel Discussion (Misc queries) 2 August 12th 08 08:36 PM
text string: "91E10" in csv file auto converts to: "9.10E+11" [email protected] Excel Discussion (Misc queries) 2 August 12th 08 03:13 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 03:45 PM.

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"