ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HowTo Count number of replacements (https://www.excelbanter.com/excel-programming/307284-re-howto-count-number-replacements.html)

Tom Ogilvy

HowTo Count number of replacements
 
msgbox application.Countif(cells,"*,*")

--
Regards,
Tom Ogilvy

"Keith Harris" wrote in message
...
Hi,

I have a simple macro which will replace one character with another:

ActiveSheet.Cells.Replace "&", "&", xlPart, xlByRows, True

Does anyone know how to return the number of replacements other than
iterating through each cell and counting -- which I imagine would be very
slow.

Thanks for any help.
-Keith




Tom Ogilvy

HowTo Count number of replacements
 
I guess you were counting amperands so

msgbox application.Countif(cells,"*&*")

however, it will only count the number of cells with ampersands. If there
are multiple ampersands in a single cell, they will only count as 1.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
msgbox application.Countif(cells,"*,*")

--
Regards,
Tom Ogilvy

"Keith Harris" wrote in message
...
Hi,

I have a simple macro which will replace one character with another:

ActiveSheet.Cells.Replace "&", "&", xlPart, xlByRows, True

Does anyone know how to return the number of replacements other than
iterating through each cell and counting -- which I imagine would be

very
slow.

Thanks for any help.
-Keith







All times are GMT +1. The time now is 12:32 AM.

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