When was a macro ran?

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
At the beginning of your macro, put something like:
Code:
Range("A1") = Now

Then cell A1 will show the last time that the macro was run.
 
Upvote 0
You can add a timestamp in the code.

I.E. Range("IV65536").Value = Now

You can also capture the user.

HTH,

Smitty
 
Upvote 0
I do not know of a way to test when macro ran unless you make the macro log that information. Here is how to do so:
Code:
Option Explicit
Sub Test()
    LogRun "Test"
End Sub
Sub LogRun(MacroName As String)
    Const TristateTrue As Long = -1
    Const ForAppending As Long = 8
    Const sMSScriptingRuntime_c As String = "Scripting.FileSystemObject"
    Const sLogPath_c As String = "C:\Test\maclog.txt"
    Const sUserName_c As String = "USERNAME"
    Const sComputerName_c As String = "COMPUTERNAME"
    Dim oFSO As Object
    Dim oTS As Object
    Set oFSO = VBA.CreateObject(sMSScriptingRuntime_c)
    Set oTS = oFSO.OpenTextFile(sLogPath_c, ForAppending, True, TristateTrue)
    oTS.WriteLine VBA.Now & vbTab & MacroName & vbTab & VBA.Environ$(sUserName_c) & vbTab & VBA.Environ$(sComputerName_c)
    oTS.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top