VBA & Macro Problems

How to Speed Up Excel VBA When Copying Filtered Rows

Maira MehtabMaira Mehtab Oct 26, 2026 869 views

Question details

The user needs to improve the execution speed of an Excel VBA macro that takes several minutes to copy and paste filtered rows from large worksheets.

How to Speed Up Excel VBA When Copying Filtered Rows
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a VBA macro to filter large datasets and copy only the visible rows to a destination worksheet.
Observed behavior
The VBA macro execution is extremely slow, sometimes taking several minutes to complete, particularly noticeable after a recent Office update.
Before you start

Before modifying your VBA code, save a backup copy of your macro-enabled workbook (.xlsm). It is also highly recommended to check for the latest Microsoft Office updates, as sudden performance bugs are frequently resolved in subsequent patches.

Solution 1Recommended

Optimize VBA Code with Direct Object Referencing

Directly referencing workbook and worksheet objects instead of relying on Select, Selection, ActiveCell, or Activate methods can drastically improve macro execution speed.

Using the .Select or .Activate methods in VBA forces the application to physically update the user interface and move the active cursor. This process requires significant processing power, especially when handling large loops or datasets. Direct object referencing interacts purely with the data in the background, executing instantaneously.

1
Remove Select and Activate methods

Review your VBA code and delete any instances of .Select, .Selection, or .Activate. Instead, use 'With' statements to directly point to your source workbook, sheet, and table objects.

2
Copy only visible cells

After applying your AutoFilter in the code, use the .SpecialCells(xlCellTypeVisible).Copy command to instruct Excel to copy only the filtered rows, ignoring hidden data.

3
Paste values and number formats

Paste the copied data directly to the destination range using .PasteSpecial Paste:=xlPasteValuesAndNumberFormats to avoid copying unnecessary background formatting that can bloat the file.

4
Clear the clipboard

Add 'Application.CutCopyMode = False' at the end of your macro to clear the clipboard and free up system memory.

Optimize VBA Code with Direct Object Referencing
Tip: Enclosing your entire block of code between Application.ScreenUpdating = False at the beginning and Application.ScreenUpdating = True at the end will further boost performance by preventing Excel from redrawing the screen while the macro runs.
WPS Spreadsheet Automation

Run Your VBA Macros Seamlessly with WPS Spreadsheet

WPS Office Spreadsheet provides excellent compatibility with Microsoft Excel VBA macros. By using WPS Office, you can execute complex macros, filter large datasets, and automate your workflow with high performance, avoiding slow execution times.

  1. 1. Download and install WPS Office: Download WPS Office from the official website and install it on your device. Open your macro-enabled workbook (.xlsm) using WPS Spreadsheet.
  2. 2. Access the Developer tab: Navigate to the 'Developer' tab on the top ribbon. If it is not visible, you can easily enable it from the WPS settings menu.
  3. 3. Run your optimized macro: Click on 'Macros', select your script for copying filtered rows, and click 'Run' to experience fast and efficient data processing.
Fully compatible with Microsoft Excel (.xlsm) macro-enabled formats.Built-in VBA editor to easily create, edit, and troubleshoot macros.Lightweight architecture optimized for fast processing of large datasets.Free to download with a familiar user interface, requiring zero learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why is the .Select method so slow in VBA?

The .Select and .Activate methods force the application to update the graphical user interface by physically moving the cursor and changing the active view. This screen updating process requires significant processing time, especially in loops, whereas direct object referencing interacts purely with the data in the background.

How does SpecialCells(xlCellTypeVisible) work in VBA?

This method targets only the cells that are currently visible on the worksheet, completely ignoring any hidden or filtered-out rows. It is a highly efficient way to copy filtered data without having to loop through every single row to check its visibility status.

Does WPS Office support Excel VBA macros?

Yes, WPS Office Spreadsheet supports VBA (Visual Basic for Applications). You can run, edit, and create macros just as you would in Microsoft Excel, providing a seamless and highly compatible automation experience.