So, I have a macro that copies sheets to new files and saves the new files with incrementally increasing names. So, the first file would be "LocalizedData1", then second would be "...2", etc.
I'm able to successfully save the first file, but later in the program, when the "pageCounter" variable has increased, the FName variable remains unchanged.
Dim FName As String
Dim FPath As String
FPath = "C:\LocalizationOutput"
FName = "LocalizedData" & pageCounter & ".xls"
ThisWorkbook.Sheets("Localized" & pageCounter).Move Before:=Workbooks.Add.Sheets(1)
Application.DisplayAlerts = False
ActiveWorkbook.Sheets("Sheet1").Delete
Application.DisplayAlerts = True
If Dir(FPath & "\" & FName) <> "" Then
MsgBox "File " & FPath & "\" & FName & " already exists. Exiting macro."
Else
ActiveWorkbook.SaveAs fileName:=FPath & "\" & FName
End If
Bookmarks