Hi there,
I'm just trying to ammend my code so that it will save the file depending on the date i.e most of my file locations are saved as:
01.January
02.February
03.March
Etc. currently my code saves it in/ or creates the folder 'March' but i just need to add the date number before the month if that makes sense and i can't work out how to add this. Please see current code below:
Thanks,
Mik
I'm just trying to ammend my code so that it will save the file depending on the date i.e most of my file locations are saved as:
01.January
02.February
03.March
Etc. currently my code saves it in/ or creates the folder 'March' but i just need to add the date number before the month if that makes sense and i can't work out how to add this. Please see current code below:
VBA Code:
Sub DateFolderSave_BS1495()
Dim strGenericFilePath As String: strGenericFilePath = "K:\Finance\Protected Funding Sheets\Money In Funding\BS1495 Funding\"
Dim strYear As String: strYear = Year(Date) & "\"
Dim strMonth As String: strMonth = MonthName(Month(Date)) & "\"
DateStamp = Format(Date, "dd-mm-yy")
Dim strFileName As String: strFileName = ("BS1495 Funding" & " " & DateStamp)
Application.DisplayAlerts = False
' Check for year folder and create if needed
If Len(Dir(strGenericFilePath & strYear, vbDirectory)) = 0 Then
MkDir strGenericFilePath & strYear
End If
' Check for month folder and create if needed
If Len(Dir(strGenericFilePath & strYear & strMonth, vbDirectory)) = 0 Then
MkDir strGenericFilePath & strYear & strMonth
End If
' Save File
ActiveWorkbook.SaveAs Filename:= _
strGenericFilePath & strYear & strMonth & strDay & strFileName, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.DisplayAlerts = True
' Popup Message
MsgBox "File Saved As: " & vbNewLine & strGenericFilePath & strYear & strMonth & strDay & strFileName
End Sub
Thanks,
Mik