Thread: Speed Question
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Speed Question

..Sort key1:=.Cells(1, 1), Order1:=xlDescending, Header:=xlYes
--
HTH...

Jim Thomlinson


"shelfish" wrote:

Three great responses. Thanks to all.

Bob,

How do I make it leave my headers alone in this sort?

Thanks again.

Bob Phillips wrote:
Sub Test()
Dim iLastRow As Long
Dim i As Long

With Selection
.Sort key1:=.Cells(1, 1), Order1:=xlDescending
i = 1
Do While .Cells(i, 1).Value 100
i = i + 1
Loop
.Cells(1, 1).Resize(i - 1).EntireRow.Delete
End With

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"shelfish" wrote in message
ups.com...
I have a couple of macros that sort through db output and delete
unwanted information

Example:
Do while selection < ""
if selection 100 hours then
selection.entirerow.delete
else offset to next row
endif
loop

Two questions:

First, is there a faster way to do this, i.e. sort for greater than 100
and delete the results?

Second, on one sheet that only has three columns this runs very fast.
(28k rows in about 15 minutes) but on another sheet with about 35
columns it only does about 2 rows a second. What is causing such a vast
difference in speed? Is it the number of columns deleted during the
entirerow.delete line?

Thanks for the help.