Created
May 3, 2013 18:15
-
-
Save brazilnut2000/5512295 to your computer and use it in GitHub Desktop.
VBA: Append timestamp to the active workbook's name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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