Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Macro speed change when closing file

In Excel20000, how come sometimes a macro runs really slowly. I
sometimes have to Control-Break the macro if it is running really slow
(many minutes). I then close Excel and rerun the same macro and it
takes only seconds. Does anyone know why this might be happening?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro speed change when closing file

Just a guess...

I'd turn calculation to manual, then do the work, then change the calculation
back to whatever it was before.

In fact, there are a few things that can slow down macros. I do this kind of
thing to speed them up:

Option Explicit
Sub testme()

Dim CalcMode As Long
Dim ViewMode As Long

Application.ScreenUpdating = False

CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

ActiveSheet.DisplayPageBreaks = False

'do the work

'put things back to what they were
Application.Calculation = CalcMode
ActiveWindow.View = ViewMode

End Sub

Your code will replace the "'do the work" line.

When/if you're hiding rows/columns, excel wants to figure out where to draw
those lines each time you change the layout.

snax500 wrote:

In Excel20000, how come sometimes a macro runs really slowly. I
sometimes have to Control-Break the macro if it is running really slow
(many minutes). I then close Excel and rerun the same macro and it
takes only seconds. Does anyone know why this might be happening?

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default Macro speed change when closing file

Can be many reasons. Could be a poorly written macro that is a memory hog.
Could be other things running on your system are pulling memory needed for
Excel. Could be the macro is not releasing memory so if you run it a number
of times, less and less memory is available for processing.
--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown


"snax500" wrote:

In Excel20000, how come sometimes a macro runs really slowly. I
sometimes have to Control-Break the macro if it is running really slow
(many minutes). I then close Excel and rerun the same macro and it
takes only seconds. Does anyone know why this might be happening?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Macro speed change when closing file

One reason this seems to vary is that you have other files in memory at the
time you're running the macro and they have overhead that if you don't do the
things Dave Peterson said to do, will cause BIG problems one time, but the
next time may not slow down much because that particular file is not in
memory. So just always do what Dave said to do and your problem should be
solved.

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
Closing file with macro dwake Excel Discussion (Misc queries) 3 December 2nd 09 05:49 PM
Closing file with Macro Louis Excel Programming 3 November 9th 07 03:32 PM
How to code on Macro on saving and closing a file? Eric Excel Worksheet Functions 1 June 10th 07 01:32 PM
run macro when closing file santee Excel Programming 2 January 30th 07 03:18 PM


All times are GMT +1. The time now is 01:06 PM.

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

About Us

"It's about Microsoft Excel"