Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 28th, 2005, 05:30 AM
Authorized User
Points: 172, Level: 3
Points: 172, Level: 3 Points: 172, Level: 3 Points: 172, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: Singapore, , Singapore.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help to define dynamic range

Hi,

I'm trying to write a code to copy some formulae from a spreadsheet named "ETSFALL" from Row 2 of Column T to AG to the rest of the rows under the same column. The problem i have is that the no. of rows is dynamic (In today's data, there's 26735 rows).

I have a code in blue below that is able to copy and paste the formula to the correct no. of rows but it is taking far too much time (> 10 mins). Does anyone know of a better way of doing this??

Please advise.
Thanks


Dim Range1 As String

Worksheets("ETSFALL").Select
ActiveCell.CurrentRegion.Select
Range1 = Selection.Rows.Count

Worksheets("ETSFALL").Cells(2, 1).Activate
Worksheets("ETSFALL").Cells(2, 1).Select
ActiveCell.CurrentRegion.Select
Count = Selection.Rows.Count

For i = 1 To Count
    Worksheets("ETSFALL").Range("T2:AG2").Copy
    Worksheets("ETSFALL").Cells(1 + i, 20).PasteSpecial
Next i



Reply With Quote
  #2 (permalink)  
Old June 28th, 2005, 08:19 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Try to set Calculation to manual while copying the formulas

Application.Calculation = xlCalculationManual
'Do some copies here
Application.Calculation = xlCalculationAutomatic

-vemaju

Reply With Quote
  #3 (permalink)  
Old June 28th, 2005, 11:01 PM
Authorized User
Points: 172, Level: 3
Points: 172, Level: 3 Points: 172, Level: 3 Points: 172, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: Singapore, , Singapore.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I managed to solve the problem. The code is shown below:

Dim Range1 As String

Worksheets("ETSFALL").Select
Worksheets("ETSFALL").Range("T2:AG2").Copy
ActiveCell.CurrentRegion.Select
Range1 = Selection.Rows.Count
Worksheets("ETSFALL").Cells(Range1, 20).Select
Worksheets("ETSFALL").Range(Selection, Selection.End(xlUp)).Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False

;p

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste Dynamic Range jgrant Excel VBA 1 February 5th, 2008 10:13 PM
Combo box can not work with dynamic Range dahlia492 Excel VBA 1 November 20th, 2006 12:43 PM
Defining a Dynamic Range using a variable Alseikhan Excel VBA 0 March 27th, 2006 02:26 AM
Can u define difference ? gvcc_neel .NET Framework 2.0 4 October 10th, 2005 04:56 AM
find name and define range for Column qball Excel VBA 4 November 17th, 2004 03:55 PM



All times are GMT -4. The time now is 07:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.