View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Clif McIrvin[_3_] Clif McIrvin[_3_] is offline
external usenet poster
 
Posts: 203
Default Macro to Convert Value to Number, Sort, then Delete

"cardan" wrote in message
...
On Mar 7, 1:12 pm, Wouter HM wrote:
Hello Dan,

In Excel 2010 I recorded the macro and added the timeGetTime function
to see how much time is needed.
I filled a single sheet with 80 colums and 8000 rows of random
figures.
Next I copied the valuesand used a formula in column A to determe is a
row should be deleted.

I have a Intel Core i3 cpu (quad core) running at 2.13 GHz and 3.0 GB
Ram.

For the single sheet I tested it on my computer needed 5553
milliseconds.
If I add a loop to select the 10 sheets you mentioned I estimate a
runtime of about 1 minute.

Option Explicit

Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub cardan()
'
' cardan Macro
'
Dim lngStart As Long
Dim lngEnd As Long

lngStart = timeGetTime
'
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.AutoFilter
Range("A1").Select
ActiveSheet.Range("$A$1:$CC$8001").AutoFilter Field:=1,
Criteria1:="Delete"
Rows("13:13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("A1").Select

lngEnd = timeGetTime

MsgBox lngEnd - lngStart & " milliseconds"

End Sub

HTH,

Wouter


Hi Wouter, thank you for the reply. I should have mentioned that I am
using Excel 2007. Not sure if that matters. I think my processing
speed is similar to yours. For some reason the macro I have takes
over a minute per page to delete the rows marked as "DELETE". When I
sort the data first and then run the macro it only takes a few
seconds. I figured if there was a way to sort the data first and then
run the macro, It would be ideal.

------------

This post by Martin Brown in another thread might shed some light on
your performance issues:

http://groups.google.com/group/micro...5a67ba46933bed

--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)