Count # of Times Sub Executes

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

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
 
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
 
Back
Top