Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Slow code to copy a row x # of times

This portion of my macro is running pretty slow. All it does is copy row 1
(with its formatting & formulas) enough times so that there will be a row for
each person in the company. We're only talking less than 500 people. Any
ideas to speed this process up? I thought about starting out with 300 rows
pre-populated (instead of 1) so my For loop could start at 300...in this
economy I'd hate to assume they will always have a minimum of 300 employees,
but if that's what it takes to speed this up, I'll do it. Many thanks!!

' Disable some features to speed up processing
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

' Add row for each employee to be imported
pct = 0
ctr = 1
imax = i
For i = i To 1 Step -1
Rows(1).Copy
Rows(13).Insert Shift:=xlDown
Rows(13).RowHeight = 12.75
Range("A13").Select
ctr = ctr + 1
pct = ctr / imax * 100
Application.StatusBar = "Importing census..." & pct & "% Complete"
Next i
Application.StatusBar = False
--
Please remember to indicate when the post is answered so others can benefit
from it later.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Slow code to copy a row x # of times

Unless I missed something, this should do what you want pretty quick. Just
adjust the receiving range for as many rows as you need. I only made it 88
for demo purposes.

Sub copyToMultRws()
Rows(1).Copy Range("A13:A100")
End Sub


"KC Rippstein" wrote:

This portion of my macro is running pretty slow. All it does is copy row 1
(with its formatting & formulas) enough times so that there will be a row for
each person in the company. We're only talking less than 500 people. Any
ideas to speed this process up? I thought about starting out with 300 rows
pre-populated (instead of 1) so my For loop could start at 300...in this
economy I'd hate to assume they will always have a minimum of 300 employees,
but if that's what it takes to speed this up, I'll do it. Many thanks!!

' Disable some features to speed up processing
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

' Add row for each employee to be imported
pct = 0
ctr = 1
imax = i
For i = i To 1 Step -1
Rows(1).Copy
Rows(13).Insert Shift:=xlDown
Rows(13).RowHeight = 12.75
Range("A13").Select
ctr = ctr + 1
pct = ctr / imax * 100
Application.StatusBar = "Importing census..." & pct & "% Complete"
Next i
Application.StatusBar = False
--
Please remember to indicate when the post is answered so others can benefit
from it later.

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
Extremely slow response times in Excel 2007 Shantanu_Das Excel Discussion (Misc queries) 4 August 10th 09 10:39 PM
Fast code in 2003 = agonizingly slow code in 2007 XP Excel Programming 25 October 21st 08 01:01 PM
Slow code when used as VBA code instead of macro (copying visible columns) [email protected] Excel Programming 3 April 2nd 07 05:26 PM
Slow in program after running few times tang lk Excel Programming 5 November 26th 04 03:37 PM
Slow Code Frank Kabel Excel Programming 1 July 23rd 04 09:28 AM


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