logandiana
Board Regular
- Joined
- Feb 21, 2017
- Messages
- 107
I have a macro that does a bunch of stuff, but then towards the end, a big spreadsheet is broken up via auto-filter and saved with each file being named an account name.
The code works great, but is a lot slower than I would have hoped. Last night I had a big list and it had to create just under 1200 files. I knew it would take a bit, but it went almost 2 hours.
I only posted the portion of the code that is taking the longest, and yes, I do have stuff like screen updating, alerts, and events, disabled at the beginning.
Any other methods I could use?
The code works great, but is a lot slower than I would have hoped. Last night I had a big list and it had to create just under 1200 files. I knew it would take a bit, but it went almost 2 hours.
I only posted the portion of the code that is taking the longest, and yes, I do have stuff like screen updating, alerts, and events, disabled at the beginning.
Any other methods I could use?
VBA Code:
For i = 2 To LR
vbs.UsedRange.AutoFilter 1, UNI.Range("B" & i).Value
Set NBK = Workbooks.Add
Set NST = NBK.Sheets(1)
vbs.UsedRange.SpecialCells(xlCellTypeVisible).Copy NST.Range("A1")
NST.Range("M1") = "Data current as of: " & Date + Time
NST.Columns("A:M").EntireColumn.AutoFit
NST.Columns("H").ColumnWidth = 40
NST.Range("H1").Font.Bold = True
NST.Range("H1").HorizontalAlignment = xlCenter
NBK.SaveAs ThisWorkbook.Path & "\SPLIT FILES\" & UNI.Range("B" & i).Value & ".xlsx"
NBK.Close True
vbs.UsedRange.AutoFilter
Next i