LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Any thoughts - VBA Slow Down with Range.Clear Command

Hi,

I use some Excel VBA code repeatedly to extract data from text files, then
to paste into new Excel workbooks, created from a template.

Now the code has worked successfully in the past, and for my current
application is taking 45 seconds to run.

In order to make my code more robust, I have added one line of code that
clears the contents of the template worksheet, before I paste in the new
data. In this way, I don't need to worry whether the previous template
"dummy" data has been overwritten.

The line of code is thus:-
Worksheets("Loads").Range("A1:H65536").Clear

Nothing too fancy you might think! However, this one extra line of code has
meant the code now takes 5 minutes to run, as opposed to 45 seconds.

Any thoughts anybody?
(I have noticed this kind of slow-down in the past: if for example I write
data to the template, then copy and paste it into the new workbook, there is
no slowdown. If I create the workbook, then write data directly to the
workbook, it takes exponentially longer.)

Thanks in advance for any thoughts,
Paul.

p.s. It is nothiong obvious like I have nested the Clear command within the
extraction loops; it is standalone, before any loops, and right after I have
created the new workbook from the template.
 
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
Copy command is slow in 2007 Winnipeg Michael Excel Discussion (Misc queries) 0 September 11th 08 07:33 PM
Command button to clear inputs mbing916 Excel Discussion (Misc queries) 7 April 2nd 07 10:26 PM
excel command to clear contents except 2 formulas Lynda S Excel Discussion (Misc queries) 6 July 14th 06 03:06 PM
How do i clear a cell using a command button? Mariann Excel Discussion (Misc queries) 1 March 30th 06 09:15 PM
shell command running very slow TTD Excel Programming 0 December 1st 04 09:43 AM


All times are GMT +1. The time now is 02:46 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"