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

  • Thread starter Thread starter michael.beckinsale
  • Start date Start date
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
 
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
 
Hi Stef,

Thanks very much, works like a dream.

I would never thought of doing that way!

Regards

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

„michael.beckinsale†ezt írta:
 
Another way to count the asterisks (just so you can see that VB is rich with possibilities) is this...

NumberOfAsterisk = UBound(Split(Range("C1"), "*"))
 
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
 
Back
Top