UnsolvedCoding
Technical User
I am having a difficult time trying to get a workbook with a variable name to close. It will open but closing it is proving to be difficult.
The reason the name is a variable is because it changes as the season progress.
Test is the variable that holds the season and two digit year
This code will open the workbook just fine.
Workbook_Name = Drive & ":\" & Season & "\" & Folder & "\" & Test & " " & "Top100.xlsx"
' Open main workbook
Workbooks.Open Filename:=Workbook_Name
But to get the workbook to close I am running out of ideas and have tried everything I can think of.
The following (and a few variations) have all failed:
Workbooks(Workbook_Name).Close SaveChanges:=False
Workbook_Name.Activate
ActiveWorkbook.Close False
Workbook_Name.Activate
ActiveWorkbook.Close SaveChanges:=False
Workbook.(Test & " " & "Top100.xlsx").close
Workbook.(Test & " " & "Top100.xlsx").close SaveChanges:=False
Any ideas?
The reason the name is a variable is because it changes as the season progress.
Test is the variable that holds the season and two digit year
This code will open the workbook just fine.
Workbook_Name = Drive & ":\" & Season & "\" & Folder & "\" & Test & " " & "Top100.xlsx"
' Open main workbook
Workbooks.Open Filename:=Workbook_Name
But to get the workbook to close I am running out of ideas and have tried everything I can think of.
The following (and a few variations) have all failed:
Workbooks(Workbook_Name).Close SaveChanges:=False
Workbook_Name.Activate
ActiveWorkbook.Close False
Workbook_Name.Activate
ActiveWorkbook.Close SaveChanges:=False
Workbook.(Test & " " & "Top100.xlsx").close
Workbook.(Test & " " & "Top100.xlsx").close SaveChanges:=False
Any ideas?