+ Reply to Thread
Results 1 to 4 of 4

Copy and paste named range at end of loop causing massive slowdown over time

  1. #1
    Registered User
    Join Date
    12-09-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    21

    Copy and paste named range at end of loop causing massive slowdown over time

    Hi all,

    So I'm currently running a fairly chunky macro that processes a load of data from different sources into, a series of nicely formatted tables on a single worksheet. Each 'table' represents one running of my loop. At the beginning and end of the loop, it pastes a named range before and after the 'table' - a range of colum headers on top and a series of pre-defined user inputs underneath, taken from a template worksheet.

    The loop has to iterate through about 10,000 'tables'. After about 500 or so, the performance begins to tail off dramatically going from about 300 loops per minute to 60. I spent the best part of a day debugging and narrowed the bottleneck down to the lines of code that paste the header / footer ranges. On removing them, performance stays fast.

    The macro is far too large to paste in here, but below is one section of the code where it pastes in the footer range. The line's immediate context is below the body of this post.

    Please Login or Register  to view this content.
    I only copy and paste the range below the table (or cluster, in the code's parlance).

    Does anybody have a clue why this would be slowing me down so radically and if so, is there anything I can do about it? I've read lots of different tips and tricks about how to optimise VBA copying and pasting, but none of them seem to have made a difference to date. Kind at my wits' end here, so any help would be massively appreciated.

    Cheers,
    Dan

    Please Login or Register  to view this content.
    Last edited by Sccye; 02-12-2013 at 06:36 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Dan

    Where is the data coming from?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-09-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copy and paste named range at end of loop causing massive slowdown over time

    The data itself is from some other worksheets. There's about 10,000 rows in one and 13,000 in the other at the moment.

    Each 'table' including the header and footer is a minimum of 30 rows, up to 60 or 70. The main sheet where everything will be pasted will probably be at least 100,000 rows, if that impacts anything.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copy and paste named range at end of loop causing massive slowdown over time

    Dan

    The reason I asked was because the problem may not be with copying of the named range, it could be something in the rest of the code.

    It might be an idea to post at least some of the rest of the code so we can, hopefully get an idea what's going on.

    An explanation in words might help too.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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