Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Excel 2007 macros with drawing objects

I have a macro that draws objects on the worksheet based on data contained in
the cells. In Excel 2003, with a worksheet of 500 lines of data, this macro
ran in about 15 seconds. In 2007, it takes upwards of 15 minutes. As the
macro works down the sheet, the process of drawing my triangles and diamonds
gets slower and slower. It seems like Excel loses processing speed as more
and more objects are drawn on the page.

Is there some way to improve this process?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default Excel 2007 macros with drawing objects

Is there some way to improve this process?

Maybe. I recorded a macro while adding a text box to a sheet. This is
basically what it boiled down to:

Activesheet.Shapes.AddTextbox(msoTextOrientationHo rizontal, 25.5, 2,
53.25, 17.25).Select

When I called basically the same macro in a loop 250 time it took 22
seconds.

The .Select is something Excel adds. Recorded code then goes on and does
other things with the 'Selection'. Much to my surprise when I removed it
the macro took .1 of a second. Yeah, 1/10 second.

So the selecting appears to be the problem. If your macro does any
selecting see if you can get rid of it. It's not always easy because
recorded code does the 'other things' with the Selection and finding the
right object and method to replace it with is not always obvious.

Sub TimeTextboxAdd()
Dim Counter As Long
Dim StTime As Double
ActiveSheet.TextBoxes.Delete
StTime = Timer
Application.ScreenUpdating = False
For Counter = 1 To 500 Step 2
AddTextBox Cells(Counter, 1).Top + 1
Next
MsgBox Timer - StTime
End Sub

Sub AddTextBox(Top As Double)
' 22 seconds
ActiveSheet.Shapes.AddTextBox(msoTextOrientationHo rizontal, 25.5, Top,
53.25, 17.25).Select
' .01 seconds
'ActiveSheet.Shapes.AddTextBox msoTextOrientationHorizontal, 25.5, Top,
53.25, 17.25
End Sub

--
Jim
"DMChesser" wrote in message
...
|I have a macro that draws objects on the worksheet based on data contained
in
| the cells. In Excel 2003, with a worksheet of 500 lines of data, this
macro
| ran in about 15 seconds. In 2007, it takes upwards of 15 minutes. As the
| macro works down the sheet, the process of drawing my triangles and
diamonds
| gets slower and slower. It seems like Excel loses processing speed as
more
| and more objects are drawn on the page.
|
| Is there some way to improve this process?


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
Group drawing objects in VBA Bubb Excel Discussion (Misc queries) 2 April 10th 06 04:22 PM
Cutting Drawing Objects LostNFound Excel Discussion (Misc queries) 3 August 12th 05 05:35 PM
HOW DO I KEEP DRAWING OBJECTS ANCHORED? HOW DO I KEEP DRAWING OBJECTS ANCHORED? Excel Discussion (Misc queries) 1 May 20th 05 01:35 PM
how can I select multiple drawing objects at once ExcelUser Excel Discussion (Misc queries) 1 February 11th 05 10:42 AM
How do I put drawing objects behind text/cells in a spreadsheet? Carl Excel Discussion (Misc queries) 1 January 19th 05 04:48 PM


All times are GMT +1. The time now is 05:17 AM.

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"