View Single Post
 
Old 05-17-2023, 05:41 PM
Jmon Jmon is offline Windows 11 Office 2019
Novice
 
Join Date: May 2023
Posts: 1
Jmon is on a distinguished road
Default Saving file with variable in file name

I am attempting to create a bunch files from a pivot table using VBA. I'm running into a problem wherein the variable is not working when saving the file.

To obtain the variable, at the start of the macro, I am using a input box. That code sits at the top of the macro, in the same module as the remaining sub's. That code:

Dim vReport_Date As String
vReport_Date = Application.InputBox("Enter Date", "Enter Report Date", "")

Then in each sub macro I am attempting to use that variable in the file name with the following code:

ActiveWorkbook.SaveAs Filename:="{Path listed here}\{set part of file name here} " & vReport_Date, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

The file is saving; however, the variable does not appear. Rather it saves as just the set part of the file name

Any suggestions would be greatly appreciated.
Reply With Quote