logandiana
Board Regular
- Joined
- Feb 21, 2017
- Messages
- 107
I have a macro that takes a table and loops through using autofilter to filter the table based on a list of values.
Then copies the new filtered table into its own new workbook, saves as, and closes it.
New files created are usually any where from 50 to 75 new workbooks based on the data in the table.
Here's the basic code that does this:
This has worked just fine for me and for many others that the program was built for.
There are a few however, where about halfway through, excel just completely crashes and closes without warning.
On the computers with this issue, when the code is running, the CPU is pegged out at 100% before the application crashes.
On my computer and others that work, the CPU% will get up to the high 90s and sometimes touch 100%, but it never just stays there causing the app to crash.
For the computers that have the apps that crash, I have made sure that they don't have other stuff running that would interfere, and made sure that they didn't have other 3rd party excel add ins enabled.
This hasn't seemed to make a difference, so rather than chalk it up to 'they just need a faster computer' to make this code work, I wonder if there is a way to slow down the macro.
Is there something I can put in the code to make it complete the same process automatically, but just take a little longer so the processor isn't taxed as much?
Or is there some alternative code that I should be using that would achieve the same goal without the burden on the processor?
Thanks
Then copies the new filtered table into its own new workbook, saves as, and closes it.
New files created are usually any where from 50 to 75 new workbooks based on the data in the table.
Here's the basic code that does this:
VBA Code:
For i = 2 To LR2
DATA.UsedRange.AutoFilter 1, UNI.Range("A" & i).Value
Set NBK = Workbooks.Add
Set NST = NBK.Sheets(1)
DATA.UsedRange.SpecialCells(xlCellTypeVisible).Copy NST.Range("A1")
NBK.SaveAs ARM.Path & "\" & who & "\SPLIT FILES\" & UNI.Range("A" & i).Value & ".xlsx"
NBK.Close True
DATA.UsedRange.AutoFilter
Next i
This has worked just fine for me and for many others that the program was built for.
There are a few however, where about halfway through, excel just completely crashes and closes without warning.
On the computers with this issue, when the code is running, the CPU is pegged out at 100% before the application crashes.
On my computer and others that work, the CPU% will get up to the high 90s and sometimes touch 100%, but it never just stays there causing the app to crash.
For the computers that have the apps that crash, I have made sure that they don't have other stuff running that would interfere, and made sure that they didn't have other 3rd party excel add ins enabled.
This hasn't seemed to make a difference, so rather than chalk it up to 'they just need a faster computer' to make this code work, I wonder if there is a way to slow down the macro.
Is there something I can put in the code to make it complete the same process automatically, but just take a little longer so the processor isn't taxed as much?
Or is there some alternative code that I should be using that would achieve the same goal without the burden on the processor?
Thanks