code works fine, but is there a faster method?

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
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
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

AutoFilter is by far the Best method ...!!!

In order to speed up your process ... just insert

1. At the top of your macro:
Application.Calculation = xlCalculationManual

2. At the end of your macro:
Application.Calculation = xlCalculationAutomatic

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top