I set up a vba macro a couple of years ago that formats a report pulled out of OneSoure, and it has worked well for me, but if the myself or another user runs it more than once while in the same instance of Excel, Excel freezes and gives the "Excel is not responding" message and I have to close it in task manager. You can save the file and excel after running it once and then when you reopen it you can run the macro again with no issues (unless again you try running it a second time). I have tried using F8 to go line by line to find the exact spot where it crashes and it works for me when I do that, but the minute I try to run it, it freezes up in the Do Until Loop, I haven't been able to pinpoint exactly, but I believe at the Selection.Columns.AutoFit line.
Full disclosure, this is sub that is called by another sub. I have attached a copy of the report the code below would be used to format, each report typically has 8-16 tabs that would be processed by one of 5 subs. When I run the macro, it takes about 50 seconds to process the full workbook (5 seconds to actually execute the code and the remaining 45 seconds is the time it takes to make the changes to page setup.
Does anyone have any thoughts on how I can fix my loop? (btw, I use Excel 2013 and my coworkers use Office 365)
Bookmarks