I have a Summary workbook with a list of Data workbook filenames.
The objective is for the Summary workbook to open the Data workbooks one at a time and have them
1) Update their data or not
2) Run Solver iterations or not
3) Save
4) Close and Return
This has been working until it doesn't work. So, the reasons are a bit hard to track down.
Right now I'm working on the "Close and Return" part.
Here is the calling Summary workbook code (simplified a bit):
What happens is this:![]()
Sub Updater() Range("D2").Select Dim cell As Range Dim sFile As String Dim flag As Boolean Application.ScreenUpdating = False ' Cells in D2:count contain path.filename.xlsm list For Each cell In Range("D2", Cells(Rows.Count, "D").End(xlUp)).Cells sFile = cell.Value Workbooks.Open sFile ActiveWorkbook.Close SaveChanges:=True Do Until WorkbookIsOpen(sFile) = False Loop Next cell Application.ScreenUpdating = True Application.EnableEvents = True End Sub
After the Workbook sFile is opened and all the steps it takes are done, it returns to the code above.
I would expect it to return to ActiveWorkbook.Close .....
But, instead it returns to Workbooks.Open sFile and, it appears, there is no value for sFile at that point.
And, the next step goes to the top of the code shown here and the same/first file is opened again.
Thanks...
Bookmarks