Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Speed up Excel execution | Excel Programming | |||
code execution speed question | Excel Programming | |||
Execution speed for UDF | Excel Programming | |||
Extremely Slow VBA Execution Speed | Excel Programming | |||
MACRO execution speed | Excel Programming |