Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brazilnut2000/5512295 to your computer and use it in GitHub Desktop.
Save brazilnut2000/5512295 to your computer and use it in GitHub Desktop.
VBA: Append timestamp to the active workbook's name
Sub AppendTimeStampToCurrentWorkbook()
Dim myName As String
Dim newName As String
Dim last_dot As Long
myName = ActiveWorkbook.fullName
' InStrRev finds last occurrence of a string in another
last_dot = InStrRev(myName, ".")
newName = Left$(myName, last_dot - 1) & " - " & Format$(Now, "MM-DD-YYYY HH.MM AM/PM") & Mid$(myName, last_dot)
MsgBox newName
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment