How do you count the number of * in a string?

M

michael.beckinsale

Hi all,

Could anybody provide the vba code to count the number of * contained
in the string of a cell. The string has leading 'spaces'

TIA

Regards

Michale
 
S

Stefi

Hi all,

Could anybody provide the vba code to count the number of * contained
in the string of a cell. The string has leading 'spaces'

TIA

Regards

Michale

If the string is in C1

occursnumber = Len(Range("C1")) - Len(Replace(Range("C1"), "*", ""))

Regards,
Stefi
 
M

michael.beckinsale

Hi Stef,

Thanks very much, works like a dream.

I would never thought of doing that way!

Regards

Michael
 
S

Stefi

You are welcome! Thanks for the feedback!
Clicking the YES button will be appreciated.
Stefi

„michael.beckinsale†ezt írta:
 
R

Rick Rothstein

Another way to count the asterisks (just so you can see that VB is rich with possibilities) is this...

NumberOfAsterisk = UBound(Split(Range("C1"), "*"))
 
S

Stefi

Another way to count the asterisks (just so you can see that VB is rich with possibilities) is this...

NumberOfAsterisk = UBound(Split(Range("C1"), "*"))

--
Rick (MVP - Excel)







- Show quoted text -

That's really tricky!
Stefi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top