ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Speed of Execution (https://www.excelbanter.com/excel-programming/398762-speed-execution.html)

Mike H.

Speed of Execution
 
I have noticed that when my code comes to things like this:
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
that it slows WAY DOWN! At the start of the subs I have this:
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Cursor = xlWait
but it still is very slow. I am in a new workbook that I just added during
the execution. Would I need to execute the enableevents statement on the
newly added wb too or is the statement at time of beginning the calling sub
sufficient? Any ideas?


Stefi

Speed of Execution
 
Try also to toggle
Application .Calculation = xlManual

Application .Calculation = xlAutomatic

Regards,
Stefi

€˛Mike H.€¯ ezt Ć*rta:

I have noticed that when my code comes to things like this:
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
that it slows WAY DOWN! At the start of the subs I have this:
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Cursor = xlWait
but it still is very slow. I am in a new workbook that I just added during
the execution. Would I need to execute the enableevents statement on the
newly added wb too or is the statement at time of beginning the calling sub
sufficient? Any ideas?


Peter T

Speed of Execution
 
All those changes to the selected cells are to formats. None of them trigger
an event or trigger calculation. So, unless your code is changing the
selection, disabling those application settings is unlikely to help, if
anything counter-productive. Same applies to calculation, don't change it
simply for this.

If the selection is extremely large re-formatting all those properties might
take a while, and probably unnecessary.

However, if you are changing the selection in some kind of loop, post the
code.

Regards,
Peter T

"Mike H." wrote in message
...
I have noticed that when my code comes to things like this:
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
that it slows WAY DOWN! At the start of the subs I have this:
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Cursor = xlWait
but it still is very slow. I am in a new workbook that I just added

during
the execution. Would I need to execute the enableevents statement on the
newly added wb too or is the statement at time of beginning the calling

sub
sufficient? Any ideas?




JP[_3_]

Speed of Execution
 
Hello,

I agree with Peter on this one, it looks like recorded code.

1- What are you trying to do with this code? Center some text? If so,
you can delete most of these instructions to make the code compact/
faster.
2- What selection are you acting on? Are you limiting the selection to
only the text you need to manipulate?


Hope this helps,
JP

On Oct 5, 5:11 am, Mike H. wrote:
I have noticed that when my code comes to things like this:
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
that it slows WAY DOWN! At the start of the subs I have this:
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Cursor = xlWait
but it still is very slow. I am in a new workbook that I just added during
the execution. Would I need to execute the enableevents statement on the
newly added wb too or is the statement at time of beginning the calling sub
sufficient? Any ideas?




All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com