hi,
How can i add a specific cell value with system dateTime when saving an excel workbook?
and if the folder doesnot exist it should create it?
e.g <FileName>_<UserName>_<SystemDateTime>.xls
Code is to be triggered when the workbook is closed?
How can i add a specific cell value with system dateTime when saving an excel workbook?
and if the folder doesnot exist it should create it?
e.g <FileName>_<UserName>_<SystemDateTime>.xls
Code is to be triggered when the workbook is closed?
Code:
Sub filename_cellvalue()
Dim Path As String
Dim filename As String
Dim strDir As String
strDir = "D:\AB\TestDir"
If Dir(strDir, vbDirectory) = "" Then
MkDir strDir
Else
MsgBox "Directory exists."
End If
filename = Range("A1")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xls", FileFormat:=xlNormal
End Sub
Last edited by a moderator: