Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit the number of times a macro can be run

Status
Not open for further replies.

Losman500

Technical User
Oct 9, 2007
43
US
Is there a way of limiting the number a macro can run? Maybe writing to a separate text file until a certain number is reached? I have some macros that I would like user to run a limited amount of times.

 


You could reset/incriment a counter in a hidden sheet from your macro.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Umm I didn't think of that. I will try it; I may need a little sample code, but let me try to figure it out first.

Thanks Skip!
 



Code:
Sub IncrimentCount()
  With Sheets("YourHiddenSheet").Cells(1,1)
    .value = .Value + 1
  End with
End sub


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Do you want to kill the macro permanently when this number has been reached or do you want to limit the number of times to within a specified time period?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top