![]() |
Count number of times macro was executed
Hi,
Can we record the number of times the macro is getting executed? Can this be recorded in a cell? Better if this can be recorded in a variable within the VBA code. By doing this i would actually limit the use of macro to senior people in the organisation i work for. Thanks in advance. Boss |
Count number of times macro was executed
Hi,
This writes the number of times the macro has been executed to a text file. Make these the first lines of your sub Sub ControlFreak() Filenum = FreeFile fname = "C:\timesrun.text" If Dir(fname) < "" Then Open fname For Input As Filenum Input #Filenum, timesrun timesrun = timesrun + 1& Close #Filenum Else timesrun = 1& End If Open "C:\timesrun.text" For Output As Filenum Print #Filenum, timesrun Close #Filenum MsgBox "This macro has been run " & timesrun & " Times" End Sub Mike "Boss" wrote: Hi, Can we record the number of times the macro is getting executed? Can this be recorded in a cell? Better if this can be recorded in a variable within the VBA code. By doing this i would actually limit the use of macro to senior people in the organisation i work for. Thanks in advance. Boss |
Count number of times macro was executed
Thanksyou so much for the code..
It helped me a lot.. Boss "Mike H" wrote: Hi, This writes the number of times the macro has been executed to a text file. Make these the first lines of your sub Sub ControlFreak() Filenum = FreeFile fname = "C:\timesrun.text" If Dir(fname) < "" Then Open fname For Input As Filenum Input #Filenum, timesrun timesrun = timesrun + 1& Close #Filenum Else timesrun = 1& End If Open "C:\timesrun.text" For Output As Filenum Print #Filenum, timesrun Close #Filenum MsgBox "This macro has been run " & timesrun & " Times" End Sub Mike "Boss" wrote: Hi, Can we record the number of times the macro is getting executed? Can this be recorded in a cell? Better if this can be recorded in a variable within the VBA code. By doing this i would actually limit the use of macro to senior people in the organisation i work for. Thanks in advance. Boss |
All times are GMT +1. The time now is 03:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com