Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Macro slow down

I have a macro which checks and merges and deletes certain lines of data
depending on the details they hold.

As this macro progresses, it starts to slow down. I have tried several
things including...
Application.cut.copymode = false
.... but nothing works. I have pinned it down to one line in the code, a
simple entirerow.delete command which can take up to 20 seconds to execute.

Does anyone know why this is happening, and how it can be rectified? It
really gets bad with about 600 lines left to delete, and i can't wait around
for 1/2 an hour to do the last little bit!

Thanks in advance for all your (anticipated) help...

Jonny
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro slow down

One way is to delete all the lines at once:

Dim rDelete As Range
Dim rCell As Range
For Each rCell In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value = "Delete Me" Then 'use your own criterion
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
'Do merge stuff here
End If
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete




In article ,
"Jonny" wrote:

I have a macro which checks and merges and deletes certain lines of data
depending on the details they hold.

As this macro progresses, it starts to slow down. I have tried several
things including...
Application.cut.copymode = false
... but nothing works. I have pinned it down to one line in the code, a
simple entirerow.delete command which can take up to 20 seconds to execute.

Does anyone know why this is happening, and how it can be rectified? It
really gets bad with about 600 lines left to delete, and i can't wait around
for 1/2 an hour to do the last little bit!

Thanks in advance for all your (anticipated) help...

Jonny

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Macro slow down

And maybe excel is trying to determine the location of those page break dotted
lines:

You might be able to fix your code with a line like this at the top:

ActiveSheet.DisplaypageBreaks = false

You may also want to turn calculation to manual, do the deletes, then turn it
back to what it was before (automatic??).

Jonny wrote:

I have a macro which checks and merges and deletes certain lines of data
depending on the details they hold.

As this macro progresses, it starts to slow down. I have tried several
things including...
Application.cut.copymode = false
... but nothing works. I have pinned it down to one line in the code, a
simple entirerow.delete command which can take up to 20 seconds to execute.

Does anyone know why this is happening, and how it can be rectified? It
really gets bad with about 600 lines left to delete, and i can't wait around
for 1/2 an hour to do the last little bit!

Thanks in advance for all your (anticipated) help...

Jonny


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro slow down tremendously

I'm having a similar situation as described by Jonny, and it happen only in
Excel 2002 (even with SP3 applied) - tested on more than one PC.

Setting calculation to manual or DisplaypageBreaks to false do not resolve
the problem.

This situation does not happen in Excel 2000 or Excel 2003.

Anyone know if this is a bug in Excel 2002, or is there a workaround.

Thank you.


"Dave Peterson" wrote:

And maybe excel is trying to determine the location of those page break dotted
lines:

You might be able to fix your code with a line like this at the top:

ActiveSheet.DisplaypageBreaks = false

You may also want to turn calculation to manual, do the deletes, then turn it
back to what it was before (automatic??).

Jonny wrote:

I have a macro which checks and merges and deletes certain lines of data
depending on the details they hold.

As this macro progresses, it starts to slow down. I have tried several
things including...
Application.cut.copymode = false
... but nothing works. I have pinned it down to one line in the code, a
simple entirerow.delete command which can take up to 20 seconds to execute.

Does anyone know why this is happening, and how it can be rectified? It
really gets bad with about 600 lines left to delete, and i can't wait around
for 1/2 an hour to do the last little bit!

Thanks in advance for all your (anticipated) help...

Jonny


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
slow macro :)[_2_] Excel Discussion (Misc queries) 1 March 3rd 10 02:41 PM
Macro - very slow run in 2003 murkaboris Excel Discussion (Misc queries) 3 September 28th 09 09:28 PM
Macro is very slow jlclyde Excel Discussion (Misc queries) 2 September 29th 08 04:43 PM
Macro it's very Slow .... leo_nunez[_2_] Excel Programming 4 August 28th 04 03:45 PM
Does OnTime slow macro down? Jeff Armstrong Excel Programming 0 August 2nd 04 08:13 PM


All times are GMT +1. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"