I am trying to add a code to save a workbook based on 3 cell values. A little background, we have a planner at work that we need to make daily backup, or copies as needed without altering the original copy of the workbook. I have tried several codes but, not having much luck.
Cell A2 example “05-2024”
Cell B2 example “Planner”
Cell C2 is a timestamp =NOW() *The date and time format is custom to display mm-dd hhmm or 05-08 1200
Sub SaveWorkbookAsXlsm()
Dim wb As Workbook
Dim folderPath As String
Dim fileName As String
Set wb = ActiveWorkbook
folderPath = "C:Art"
fileName = wb.Sheets("Sheet1").Range("A2").Value & "_" & _
wb.Sheets("Sheet1").Range("B2").Value & "_" & _
wb.Sheets("Sheet1").Range("C2").Value & ".xlsm"
wb.SaveAs fileName:=folderPath & fileName, FileFormat:=52
End Sub
Is there a better way?
I tried the above code, it did not work. I am trying to save the workbook based on cells A2, B2 & C2. When we begin a new month we create a copy of our planner and basically name it for example 05-2024 Planner. We need to make backup saves periodically with the date and time. I am trying to code the worbook to save based on the cell values to simplify the process.
Arthur Naron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.