Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default identical macros run fast and slow

I have written two identical Macros using Visual Basic. The only difference
in the code are the variables that are inputted. the code contains
directions that cause lines to be hidden or cells to be erased based upon
either the color or content of the cells. One macro runs fast but the other
runs very slow. Ive contacted IBM and they say it is not the processor.
When viewing the code in the debug mode the selection.clearcontents seems to
cause a pause in the execution but only in the one macro.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default identical macros run fast and slow

If you're hiding rows or columns, then excel may be trying to determine where
those little dotted lines go (the ones you see after you do File|print preview).

If you delete/hide/show lots of rows, this can slow your macro down.

As a test, try this on the slow version.

Open your workbook
tools|options|view tab|uncheck Page Breaks

Then run your macro. If it works fast, then maybe you found the problem.

===
Saved from a previous post...


There are some other settings that can make your code work faster:

Application.ScreenUpdating = False
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
ActiveSheet.DisplayPageBreaks = False


The first stops the screen flickering when you select different sheets (but it's
even better to not select sheets/ranges/objects).

The second & third line turns calculation to manual (and remembers the current
setting).

You'll want to turn it back to what it was before you started at the end:
Application.calculation = calcmode

And the last tells excel to not worry about where to show those dotted lines
(where page breaks would be). This is useful if your macro inserts/deletes rows
or columns.

markwattwood wrote:

I have written two identical Macros using Visual Basic. The only difference
in the code are the variables that are inputted. the code contains
directions that cause lines to be hidden or cells to be erased based upon
either the color or content of the cells. One macro runs fast but the other
runs very slow. Ive contacted IBM and they say it is not the processor.
When viewing the code in the debug mode the selection.clearcontents seems to
cause a pause in the execution but only in the one macro.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default identical macros run fast and slow



"Dave Peterson" wrote:

If you're hiding rows or columns, then excel may be trying to determine where
those little dotted lines go (the ones you see after you do File|print preview).

If you delete/hide/show lots of rows, this can slow your macro down.

As a test, try this on the slow version.

Open your workbook
tools|options|view tab|uncheck Page Breaks

Then run your macro. If it works fast, then maybe you found the problem.

===
Saved from a previous post...


There are some other settings that can make your code work faster:

Application.ScreenUpdating = False
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
ActiveSheet.DisplayPageBreaks = False


The first stops the screen flickering when you select different sheets (but it's
even better to not select sheets/ranges/objects).

The second & third line turns calculation to manual (and remembers the current
setting).

You'll want to turn it back to what it was before you started at the end:
Application.calculation = calcmode

And the last tells excel to not worry about where to show those dotted lines
(where page breaks would be). This is useful if your macro inserts/deletes rows
or columns.

markwattwood wrote:

I have written two identical Macros using Visual Basic. The only difference
in the code are the variables that are inputted. the code contains
directions that cause lines to be hidden or cells to be erased based upon
either the color or content of the cells. One macro runs fast but the other
runs very slow. Ive contacted IBM and they say it is not the processor.
When viewing the code in the debug mode the selection.clearcontents seems to
cause a pause in the execution but only in the one macro.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default identical macros run fast and slow

I checked the view bar and you are right. the page breaks is not checked in
one, but in the slow one it is in grey and will not uncheck. Ive unprotected
the sheet . All other settings are identical to the fast macro.

"Dave Peterson" wrote:

If you're hiding rows or columns, then excel may be trying to determine where
those little dotted lines go (the ones you see after you do File|print preview).

If you delete/hide/show lots of rows, this can slow your macro down.

As a test, try this on the slow version.

Open your workbook
tools|options|view tab|uncheck Page Breaks

Then run your macro. If it works fast, then maybe you found the problem.

===
Saved from a previous post...


There are some other settings that can make your code work faster:

Application.ScreenUpdating = False
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
ActiveSheet.DisplayPageBreaks = False


The first stops the screen flickering when you select different sheets (but it's
even better to not select sheets/ranges/objects).

The second & third line turns calculation to manual (and remembers the current
setting).

You'll want to turn it back to what it was before you started at the end:
Application.calculation = calcmode

And the last tells excel to not worry about where to show those dotted lines
(where page breaks would be). This is useful if your macro inserts/deletes rows
or columns.

markwattwood wrote:

I have written two identical Macros using Visual Basic. The only difference
in the code are the variables that are inputted. the code contains
directions that cause lines to be hidden or cells to be erased based upon
either the color or content of the cells. One macro runs fast but the other
runs very slow. Ive contacted IBM and they say it is not the processor.
When viewing the code in the debug mode the selection.clearcontents seems to
cause a pause in the execution but only in the one macro.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default identical macros run fast and slow

It sounds like you're viewing the window in Page Break Preview mode.

View|Normal

And with that added code, it should work quicker.



markwattwood wrote:

I checked the view bar and you are right. the page breaks is not checked in
one, but in the slow one it is in grey and will not uncheck. Ive unprotected
the sheet . All other settings are identical to the fast macro.

"Dave Peterson" wrote:

If you're hiding rows or columns, then excel may be trying to determine where
those little dotted lines go (the ones you see after you do File|print preview).

If you delete/hide/show lots of rows, this can slow your macro down.

As a test, try this on the slow version.

Open your workbook
tools|options|view tab|uncheck Page Breaks

Then run your macro. If it works fast, then maybe you found the problem.

===
Saved from a previous post...


There are some other settings that can make your code work faster:

Application.ScreenUpdating = False
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
ActiveSheet.DisplayPageBreaks = False


The first stops the screen flickering when you select different sheets (but it's
even better to not select sheets/ranges/objects).

The second & third line turns calculation to manual (and remembers the current
setting).

You'll want to turn it back to what it was before you started at the end:
Application.calculation = calcmode

And the last tells excel to not worry about where to show those dotted lines
(where page breaks would be). This is useful if your macro inserts/deletes rows
or columns.

markwattwood wrote:

I have written two identical Macros using Visual Basic. The only difference
in the code are the variables that are inputted. the code contains
directions that cause lines to be hidden or cells to be erased based upon
either the color or content of the cells. One macro runs fast but the other
runs very slow. Ive contacted IBM and they say it is not the processor.
When viewing the code in the debug mode the selection.clearcontents seems to
cause a pause in the execution but only in the one macro.


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default identical macros run fast and slow

right again
thanks

"Dave Peterson" wrote:

It sounds like you're viewing the window in Page Break Preview mode.

View|Normal

And with that added code, it should work quicker.



markwattwood wrote:

I checked the view bar and you are right. the page breaks is not checked in
one, but in the slow one it is in grey and will not uncheck. Ive unprotected
the sheet . All other settings are identical to the fast macro.

"Dave Peterson" wrote:

If you're hiding rows or columns, then excel may be trying to determine where
those little dotted lines go (the ones you see after you do File|print preview).

If you delete/hide/show lots of rows, this can slow your macro down.

As a test, try this on the slow version.

Open your workbook
tools|options|view tab|uncheck Page Breaks

Then run your macro. If it works fast, then maybe you found the problem.

===
Saved from a previous post...


There are some other settings that can make your code work faster:

Application.ScreenUpdating = False
CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual
ActiveSheet.DisplayPageBreaks = False


The first stops the screen flickering when you select different sheets (but it's
even better to not select sheets/ranges/objects).

The second & third line turns calculation to manual (and remembers the current
setting).

You'll want to turn it back to what it was before you started at the end:
Application.calculation = calcmode

And the last tells excel to not worry about where to show those dotted lines
(where page breaks would be). This is useful if your macro inserts/deletes rows
or columns.

markwattwood wrote:

I have written two identical Macros using Visual Basic. The only difference
in the code are the variables that are inputted. the code contains
directions that cause lines to be hidden or cells to be erased based upon
either the color or content of the cells. One macro runs fast but the other
runs very slow. Ive contacted IBM and they say it is not the processor.
When viewing the code in the debug mode the selection.clearcontents seems to
cause a pause in the execution but only in the one macro.

--

Dave Peterson


--

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
Macros Running Sometimes Slow Sometimes Fast bigV Excel Discussion (Misc queries) 0 June 9th 08 03:13 PM
Runs fast then slow rpw Excel Programming 17 February 28th 07 10:32 PM
Searches slow for some Fast for others? [email protected] Excel Worksheet Functions 0 August 4th 05 08:54 PM
Why macro slow on one, fast on another? CLR Excel Programming 4 April 4th 05 01:09 PM
It was SLOW, now is FAST! Phillips Excel Programming 6 November 21st 03 10:21 PM


All times are GMT +1. The time now is 10:42 PM.

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"