Hello, I am trying to add into my code to look for a folder in the save location by year. So, for example: if the year changes from 2023 to 2024, the VBA code will automatically save into the 2024 folder. I hope my terrible explanation makes some sense...
Dim newFolder As StringPlease Login or Register to view this content.
newFolder = Range("c56").Value
Dim arr1 As Variant
arr1 = Array("certificate (2)", "certificate")
' only create folder if it doesn't already exist
If Len(Dir(path & newFolder, vbDirectory)) = 0 Then MkDir path & newFolder
' update path to include the new folder
path = path & newFolder & Application.PathSeparator
Dim FileName As String
FileName = newFolder & ".xlsm"
ActiveWorkbook.SaveCopyAs path & FileName
ActiveWorkbook.Sheets(arr1).Select
ActiveSheet.ExportAsFixedFormat xlTypePDF, Replace$(path & FileName, ".xlsm", ".pdf")
MsgBox " Certificate Saved Successfully"
End Sub[/CODE]
Thanks.
Bookmarks