logandiana
Board Regular
- Joined
- Feb 21, 2017
- Messages
- 107
I wrote this code for a project. It filters two tabs then appends one set of values to the bottom of the other and then saves the result to a new file. It works fine, but sometimes with 100 or more values for "i" it can take a while. Any suggestions or different code to make it run faster?
Thanks in advance
Thanks in advance
Code:
Application.ScreenUpdating = False
LR1 = REP.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LR1
If REP.Cells(i, 2).Value = "None" Then
GoTo Nexti
End If
Z8C1.UsedRange.AutoFilter 4, REP.Range("A" & i).Value
Z8C3.UsedRange.AutoFilter 8, REP.Range("B" & i).Value
Set NBK = Workbooks.Add
Set NST = NBK.Sheets(1)
Z8C1.UsedRange.SpecialCells(xlCellTypeVisible).Copy NST.Range("A1")
LRNST = NST.Cells(Rows.Count, 1).End(xlUp).Row
Z8C3.UsedRange.SpecialCells(xlCellTypeVisible).Copy NST.Range("A" & LRNST + 1)
NST.Rows(LRNST + 1).Delete
NST.Columns("A:I").EntireColumn.AutoFit
NBK.SaveAs Panx.Path & "\SPLIT FILES\" & REP.Range("A" & i).Value & ".xlsx"
NBK.Close True
Z8C1.UsedRange.AutoFilter
Z8C3.UsedRange.AutoFilter
Nexti:
Next i
Application.ScreenUpdating = True