ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count # of Times Sub Executes (https://www.excelbanter.com/excel-programming/271686-count-times-sub-executes.html)

Mike[_32_]

Count # of Times Sub Executes
 
Is there a way to keep track as to the number of times a
button is clicked. I have a command button on one of my
sheets and would like to keep track as to the number of
times a person runs the program. I would like to reset the
value when Excel closes.

Thanks,
Mike

pancho[_2_]

Count # of Times Sub Executes
 
I suggest, you use a Hidden sheet, so you can do the
following things on that sheet,
1.- On excel:
Tools/Macro/VisualBasic Editor/
on VisualBasicEditor:
View/Project Explorer/
View/Properties Window
--select the sheet you want to hide
(name it "MyCounter")---
on properties, select the Visible property
and set it to "2 - xlSheetVeryHidden"
File/Close and return toi Microsoft Excel)

2.- On the auto_open macro, you can set the value to zero,
( say A1), on the execution of you macro you can set the
value of that particular cell to the previous value plus
one, with:

With Thisworkbook.sheets("MyCounter").Range("A1")
.Value=.Value + 1
End With

You can see the value using:
Thisworkbook.sheets("MyCounter").Range("A1").Value

Francisco Mariscal



-----Original Message-----
Is there a way to keep track as to the number of times a
button is clicked. I have a command button on one of my
sheets and would like to keep track as to the number of
times a person runs the program. I would like to reset

the
value when Excel closes.

Thanks,
Mike
.



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

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