An implementation of Visual Basic that is built into Microsoft products.
Hi @Jacques Abel ,
Thanks for reaching out.
The fact that this works in debug mode but not when the macro runs normally does suggest the issue is more likely related to Excel state or timing than to the general VBA approach itself.
Since you already said you are explicitly saving and closing the target workbook, I would not treat the basic Save / Close pattern itself as the real issue here. I would look more closely at what Excel may still be doing in the background at the moment the close happens.
The adjustment I would try is to keep the same workbook-object approach, avoid ActiveWorkbook, and add a small processing gap between the save and the close so Excel can finish any pending events, calculation, or async activity.
wbTarget.Save
DoEvents
Application.CalculateUntilAsyncQueriesDone
wbTarget.Close SaveChanges:=True
If the workbook depends on calculation, you can also force calculation before the save. It is also worth confirming that the target workbook is not opening as read-only, because that can make the macro appear to run correctly while nothing is actually written back to disk.
If events, queries, or other automation are involved, temporarily disabling events during the operation can also help stabilize it:
Application.EnableEvents = False
' your logic here
Application.EnableEvents = True
I would also keep an eye on where the file is stored. If it is on OneDrive, SharePoint, or a network location, sync or background file handling can sometimes interfere with this kind of automation. The same goes for workbooks using Power Query, external links, RTD, or anything asynchronous.
If Save still does not persist the changes, a useful diagnostic test is to try a same-name SaveAs, because that forces Excel to write the file again more aggressively.
Overall, your approach is valid. Based on the behavior you described, this looks more like Excel is not fully completing the save process when the macro runs at full speed than like something fundamentally wrong in your VBA.
If this started right after a specific Excel update and the above does not stabilize it, I would check the exact build under File > Account > About Excel and compare it with Microsoft's official update history for Microsoft 365 Apps:
https://learn.microsoft.com/en-us/officeupdates/update-history-microsoft365-apps-by-date
You can also use Microsoft's overview of update channels to confirm which release channel the installation is on:
https://learn.microsoft.com/en-us/DeployOffice/overview-of-update-channels-for-office-365-proplus
That gives you a way to confirm whether the behavior started with a specific build and whether a newer build is already available for your update channel.
If you can reproduce it consistently on the same build, it would also be worth sending feedback from Excel through File > Feedback > I don't like something, so the product team gets the exact build details along with the report.
Hope this helps! If my explanation and the information I provided were helpful to you, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.