Hi I use below to save my work after I run all my vba, but I need to add something to this if I can. Right now it save file name and time as you can see
SaveName ="LCP Complete File" & Format(Now, "HH.MM.SS") .
but I need to add the date of the ending period that's on active sheet I'm saving. The date it always in E2. Any possible way of adding this to this.
Results now when saved LCP Complete File16.42.40
Trying to get this result -->LCP Complete File16.42.40 - 2/25/2018 <-- this is in E2 alwaysbut I need to add the date of the ending period that's on active sheet I'm saving. The date it always in E2. Any possible way of adding this to this.
Results now when saved LCP Complete File16.42.40
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Sub SaveFileButtonDateLCP40() '---LCP File Save---'[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim SaveName As String[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Const MyPath As String = "C: 'This is the path it's using for savesbefore the dates[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]ReName:[/COLOR][/SIZE][/FONT]
[SIZE=3][COLOR=#000000][FONT=Calibri] SaveName ="LCP Complete File" & Format(Now, "HH.MM.SS") ‘[/FONT][FONT=Wingdings]ß[/FONT][FONT=Calibri]Add date here[/FONT][/COLOR][/SIZE]
[FONT=Calibri][SIZE=3][COLOR=#000000] If Len(SaveName)> 0 Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] SaveName =SaveName & ".xlsx"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] IfLen(Dir(MyPath & Format(Now, "yy") & "-" &Format$(Now, "mmm"), vbDirectory)) = 0 Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] MkDirMyPath & Format(Now, "yy") & "-" & Format$(Now,"mmm") & "\"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End If[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] IfLen(Dir(MyPath & Format(Now, "yy") & "-" &Format$(Now, "mmm") & "\" & Format(Now,"mm") & "-" & Format(Now, "dd") &"-" & Format(Now, "yyyy"), vbDirectory)) = 0 Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] MkDirMyPath & Format(Now, "yy") & "-" & Format$(Now,"mmm") & "\" & Format(Now, "mm") &"-" & Format(Now, "dd") & "-" &Format(Now, "yyyy") & "\"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End If[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] ActiveWorkbook.SaveAs Filename:=MyPath & Format(Now, "yy")& "-" & Format$(Now, "mmm") & "\"& Format(Now, "mm") & _[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] "-" & Format(Now, "dd") & "-"& Format(Now, "yyyy") & "\" & SaveName,FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End If[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] MsgBox "Savedin Folder"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Exit Sub[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]ErrorHandle:[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] If Err.Number = 75Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Resume Next[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] ElseIf Err.Number= 1004 Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] MsgBox("That name is already used for this day. Please try again!")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] GoTo ReName[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Else: MsgBox("There is an unknown error")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End If[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]