In this tutorial, we demonstrate why looping through rows and deleting them one by one is an extremely inefficient use of VBA in Excel. For datasets over 10,000 rows, this process can take minutes or even hours.
We show you the high-performance VBA code that achieves the same result by simply filtering for the data you want to keep, copying that visible data to a new sheet, and deleting the old sheet. This one-time delete action is exponentially faster than the standard delete method. We test this method on a worksheet with over 1 million rows of data.
0:00 | Introduction & Why Looping is Slow
0:34 | The 1 Million Row Test Data Setup
0:58 | The "Filter & Copy" Strategy Explained
1:36 | Starting the VBA Sub & Declaring Variables
3:42 | Essential: Turning ScreenUpdating Off
4:57 | The Fast Action: AutoFilter, Copy, & PasteSpecial
8:09 | Deleting the Old Worksheet in VBA
9:12 | Renaming the New Worksheet
12:32 | Final Performance Result: Deleting Rows Took 15 Seconds