View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using SpecialCells().EntireRow.Delete on large worksheet - Very slow!

I believe the method you are using is the fastest. I doubt you would gain
anything by breaking it into pieces. Certainly the suggestion of doing it
one row at a time I wouldn't think would be an improvement. Plus, as
written it would error out on the first row that doesn't get deleted.

You should be aware that specialcells can not select more than 8192 areas.

If your rows contain formulas or you have other sheets that reference data
in this sheet, then you might make sure you have set calculation to manual.

If you want to pursue your 100 at a time, you might want to work from the
bottom up, but I think it is just going to take some time to delete a lot of
rows on a sheet that big although 10 minutes doesn't sound right.

--
Regards,
Tom Ogilvy


"Ilan" wrote in message
m...
Hi all
I have a large worksheet (~60,000 rows) that includes mostly numeric
data and some text rows. I need to delete entire rows that have text
in the cell at column A.
I wrote the following code that selects column A (MyRange) and deletes
the entire row if a text value if found. it works fine, but extremely
slow (~10 min):

Sheets(My_Sheet).Select
MyRange.Select
MyRange.SpecialCells(xlCellTypeConstants,
xlTextValues).EntireRow.Delete

I suspected there is a memory issue working with such a large range at
once, so I tried looping every 100 rows. At first it worked realy
fast, but started to slow again until it finaly took the same amount
of time as before.
If this is a memory issue, is there a way to free the memory inside
the loop? If not, is the a more efficient way to do this?

Thanks,
Ilan