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
|