When was a macro ran?

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
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

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
You can add a timestamp in the code.

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

You can also capture the user.

HTH,

Smitty
 
Upvote 0

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
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,190,795
Messages
5,982,967
Members
439,808
Latest member
agutosay

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
Top