So I am trying to create a journal entry template that will create the file name based on named ranges within the worksheet and save it in the current folder the template is saved in. Below is the code I have thus far but it keeps debugging at the ActiveWorkbook.SaveAs line. Also, I have confirmed that the named ranges work correctly by pulling them into the spreadsheet with a macro just to make sure that wasn't a problem.
Sub Save()
Dim Initials As String
Dim Entity As String
Dim Create_Date As String
Dim Batch As String
Dim Journal_Name As String
Initials = Range("Initials")
Entity = Range("Entity")
Create_Date = Range("Date")
Batch = Range("Batch")
Journal_Name = Range("Journal_Name")
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & Initials & "-" & Entity & "-" & Create_Date & "-" & Batch & "-" & Journal_Name & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
I have the below code that I patterned this one after from another file that works fine so I can't figure out why this one is debugging, someone please help! The ; isn't what is causing it to debug, that is from the code I copied from that is actually working. I'm not using the ; in the code that is debugging.
Sub Format()
Dim Year As Integer
Dim Month1
Dim Month2
Year = InputBox("Enter the Year", "Year", "YYYY")
Month1 = InputBox("Enter the Month", "Month", "M")
Month2 = WorksheetFunction.Text(Month1, "00")
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & Year & Month2 & "-janusus;import-actual-" & Year & "M" & Month1 & "-R.csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False
End Sub