Hello,
I'm having trouble with the final part of this bit of VBA code. I'm trying to create a macro that will create folders for (Year) (Month) (Day) if theyre are not there - This is done and working.
However when I get to the save, the file saves to the Month folder rather than the Day folder. - Do I need to declare the Day folder name as a variable for it to recognise the path?
Secondly, the file is saving with the file name of the date (suggesting that in this line it's taking the date as the file name rather than the folder path?)
Here is the code
Code
Sub DateFolderSave()
Application.DisplayAlerts = False
' Check for year folder and create if needed
If Len(Dir("C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date), vbDirectory)) = 0 Then
MkDir "C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date)
End If
' Check for month folder and create if needed
If Len(Dir("C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date) & "\" & MonthName(Month(Date), False), vbDirectory)) = 0 Then
MkDir "C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date) & "\" & MonthName(Month(Date), False)
End If
' Check for date folder and create if needed
If Len(Dir("C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & Format(Date, "dd.mm.yy"), vbDirectory)) = 0 Then
MkDir "C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & Format(Date, "dd.mm.yy")
End If
' Save File
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\Christine\Desktop\Learner Lists LC\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & Format(Date, "dd.mm.yy") & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.DisplayAlerts = True
' Popup Message
MsgBox "File Saved As:" & vbNewLine & "C:\Users\Desktop\Learner Lists LC\" & Year(Date) & _
"\" & MonthName(Month(Date), False) & "\" & Format(Date, "mm.dd.yy") & ".xlsm"
End Sub
Display More
Thanks in advance for any help offered