View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert McCurdy Robert McCurdy is offline
external usenet poster
 
Posts: 102
Default making macro run faster?

You don't need to select or delete.
Can you not sort it?
If you insert a column and use a formula to find your string.

[YourRange].formula = "=IF(D2="INFORMATION",0,"ZZ")

YourRange is the range of the column adjacent to your data.
Sort with this column then delete or Clear (preferably) the rows with 0.
If you need a macro just record the process.
Or have a look at this one. (Here I assumed you have headers in
A1 to F1, and the formula column is the 6th one)


Sub DellInfo()
[F2:F30000].Formula = "=IF(D2=""INFORMATION"",0,""ZZ"")"
[A1:F30000].Sort key1:=[F2], order1:=xlAscending, header:=xlGuess
[A2].Resize(Application.Count([F2:F30000]), 6).Delete shift:=xlUp
End Sub


This will take about a second on a slow machine.
To delete the formula column via code
Columns(6).clear
I left it in to see the results, or for you to delete it manually.


Regards Robert

"goorooj " wrote in message ...
hi,

currently i´m using this loop

x = 1

While Cells(x, 1) < "Endlog"
If Cells(x, 4) = "INFORMATION" Then
Range("A" & x & ":K" & x).Select
Range("A" & x & ":K" & x).Delete
x = x - 1
End If

x = x + 1

Wend

in a macro to delete all rows from a sheet that contain the term
information in column 4, it´s for log file viewing.

endlog is the last word in the sheet.
it works fine, but:

deleting up to 30.000 rows in a sheet this way takes quite a long time,
up to half an hour... is there any way to make the task run faster?
with a do...loop or any other, faster working loop?


---
Message posted from http://www.ExcelForum.com/



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.590 / Virus Database: 373 - Release Date: 17/02/2004