ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do you count the number of * in a string? (https://www.excelbanter.com/excel-programming/438415-how-do-you-count-number-%2A-string.html)

michael.beckinsale

How do you count the number of * in a string?
 
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

Stefi[_2_]

How do you count the number of * in a string?
 
On Jan 14, 1:22*pm, "michael.beckinsale"
wrote:
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

michael.beckinsale

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

Thanks very much, works like a dream.

I would never thought of doing that way!

Regards

Michael


Stefi

How do you count the number of * in a string?
 
You are welcome! Thanks for the feedback!
Clicking the YES button will be appreciated.
Stefi

€˛michael.beckinsale€¯ ezt Ć*rta:

Hi Stef,

Thanks very much, works like a dream.

I would never thought of doing that way!

Regards

Michael

.


Rick Rothstein

How do you count the number of * in a string?
 
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)


"michael.beckinsale" wrote in message ...
Hi Stef,

Thanks very much, works like a dream.

I would never thought of doing that way!

Regards

Michael


Stefi[_2_]

How do you count the number of * in a string?
 
On Jan 14, 6:02*pm, "Rick Rothstein"
wrote:
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)



"michael.beckinsale" wrote in ...
Hi Stef,


Thanks very much, works like a dream.


I would never thought of doing that way!


Regards


Michael- Hide quoted text -


- Show quoted text -


That's really tricky!
Stefi


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com