View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen[_4_] Stephen Bullen[_4_] is offline
external usenet poster
 
Posts: 205
Default Bulk Row Deletion - Fastest method

Hi Quartz,

The fastest method I have found in benchmarking tests is to:

1. Use a "For...Each" loop to mark the rows for deletion in the sheet
2. Sort the data so that all the target rows are together
3. Delete all the target rows at the same time
4. If necessary, re-sort the data


I would do the following:

1. Put a formula in all the cells to identify which ones to delete,
0=keep, 1=delete
2. Sort the data by that column, leaving the '1's at the bottom
3. Count the '1's column, which gives the number to delete
4. Delete all the '1' rows in one go.
5. Clear the column of formulas

There's no need for a re-sort, as all the 'kept' data will be in its
original order.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk