Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Should I be content with the time code takes?

This copy/paste special code is the last part of a macro that I run 100 times in a loop.

Using a timer, it takes 5.397 seconds to run. It produces 2000 rows of output data. Not too bad in my eyes.

If I comment out the copy lines, the macro runs 100 times in .847 seconds. (Thanks Claus)

I am not unhappy with the 5 + seconds run time, and the six square wheeled copy wagons the macro has to drag along are necessary.

Was just wondering if the copy paste could be written to be quicker. If not, I am still a happy camper and content with the 5 + seconds.

I pondered an array approach, but the six ranges to six different destinations were beyond me.

Thanks,
Howard

Range("AQ2:AQ21").Copy
Range("AE" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Range("AQ24:AQ43").Copy
Range("AG" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Range("AQ46:AQ65").Copy
Range("AI" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Range("AQ68:AQ87").Copy
Range("AK" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Range("AQ90:AQ109").Copy
Range("AM" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Range("AQ112:AQ131").Copy
Range("AO" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Should I be content with the time code takes?

Hi Howard,

Am Fri, 14 Mar 2014 03:54:49 -0700 (PDT) schrieb L. Howard:

This copy/paste special code is the last part of a macro that I run 100 times in a loop.

Using a timer, it takes 5.397 seconds to run. It produces 2000 rows of output data. Not too bad in my eyes.


try:

Sub MyCopy()
Dim i As Long
Dim arrOut As Variant
Dim myCol As Long

myCol = 31
For i = 2 To 112 Step 22
arrOut = Range("AQ" & i).Resize(rowsize:=20)
Cells(Rows.Count, myCol).End(xlUp).Offset(1, 0) _
.Resize(rowsize:=20) = arrOut
myCol = myCol + 2
Next
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Should I be content with the time code takes?

On Friday, March 14, 2014 4:36:03 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Fri, 14 Mar 2014 03:54:49 -0700 (PDT) schrieb L. Howard:



This copy/paste special code is the last part of a macro that I run 100 times in a loop.




Using a timer, it takes 5.397 seconds to run. It produces 2000 rows of output data. Not too bad in my eyes.




try:



Sub MyCopy()

Dim i As Long

Dim arrOut As Variant

Dim myCol As Long



myCol = 31

For i = 2 To 112 Step 22

arrOut = Range("AQ" & i).Resize(rowsize:=20)

Cells(Rows.Count, myCol).End(xlUp).Offset(1, 0) _

.Resize(rowsize:=20) = arrOut

myCol = myCol + 2

Next

End Sub





Regards

Claus B.

--


Indeed, drops it back to 1.532 seconds.

Mighty fine!

Thanks Claus.

Howard
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
Code takes a long time to process Sandy Excel Programming 1 June 19th 08 08:08 PM
ODBC takes time to update kaiser Excel Programming 2 June 12th 07 01:34 PM
Save takes long time Jan Excel Discussion (Misc queries) 2 February 15th 06 06:01 PM
Get time it takes to run program!! cjsasl Excel Programming 8 November 11th 05 09:32 PM
Calculating Time in XP takes forever Dan Excel Discussion (Misc queries) 3 December 22nd 04 10:06 PM


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