+ Reply to Thread
Results 1 to 3 of 3

Faster Way to Copy and Paste Values

Hybrid View

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    Des Moines, IA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Faster Way to Copy and Paste Values

    Hi everyone, I have the following segment of code to run through 500 scenarios and copy and paste certain results onto a Results sheet:

    Formula: copy to clipboard
    For i = 1 To 500
    For j = 0 To 14
    Sheets("Inputs").Range("B4") = i
    Sheets("Rates").Activate
    Call SolveRates
    Sheets("Rates").Range("D" & j & 7).Copy
    Sheets("Results").Cells(3 + j, i + 1).PasteSpecial Paste:=xlPasteValues
    Sheets("Rates").Range("D" & j & 8).Copy
    Sheets("Results").Cells(25 + j, i + 1).PasteSpecial Paste:=xlPasteValues
    Sheets("NCFs").Range("AO" & j & 9).Copy
    Sheets("Results").Cells(47 + j, i + 1).PasteSpecial Paste:=xlPasteValues
    Next j
    Next i

    End Sub
    Right now it takes pretty long to run through all 500 scenarios, and I was wondering if anyone has any tips on how to clean up this code and make it run faster.

    Thanks!
    Last edited by mpjennings25; 07-08-2013 at 11:38 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Faster Way to Copy and Paste Values

    Please use code tags with your code as per form's rule.
    It is difficult to comment as you have another call code, but generally speaking avoid using like select and activate.
    You also nee dto use screen updating.
    Application.ScreenUpdating = 0
    after the dim statement
    Application.ScreenUpdating = True
    before the end of sub

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Faster Way to Copy and Paste Values

    For every row you are looping through 14 times in columns.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1