At one point in my macro, I will have a workbook called "x" (this workbook name will change often), and another workbook called "y" (name will remain constant).
At a a point in my macro, it only has "x" open, then saves it, and opens up "y". I then want it to close "x" but I can't figure out how to get it to close "x":
When the last part of the code is executed, it closes "y" because that is the active workbook since it was just opened. How do I get it to select workbook "X" and close it. It would be easy if "X" had a constant name but it is always changing. Also, this will be part of a looped code, where "Y" is a template.
At a a point in my macro, it only has "x" open, then saves it, and opens up "y". I then want it to close "x" but I can't figure out how to get it to close "x":
Code:
ActiveWorkbook.Save (workbook "x")
Workbooks.Open Filename:="E:\Groups\Hyperion\Acterna\Corp\FY2004\" & Month & "\Entity Pack Template.xls" (workbook "y")
ActiveWorkbook.Close (want this to be Workbook "x", but it closes "y")
When the last part of the code is executed, it closes "y" because that is the active workbook since it was just opened. How do I get it to select workbook "X" and close it. It would be easy if "X" had a constant name but it is always changing. Also, this will be part of a looped code, where "Y" is a template.