+ Reply to Thread
Results 1 to 4 of 4

Can a VBA run too fast?

  1. #1
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Can a VBA run too fast?

    Hi again,

    I'm currently running a code that appears to run perfectly but...rather than copying the last row that the code populates, it copies the previous row (the last but 1)? I thought maybe the code was running too fast so i incorporated a 1 second delay, then a 3 & now a 10 second delay without success...can anyone see where i'm going wrong? Thank you all once again - Marco

    Code as follows:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520
    Add Lastrow +1 to range you are coping. Because at the start of your code you get lastrow then you add data to the Lastrow + 1. So you need to add +1 to the range you are coping.

    And remove the wait don't need it.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    07-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007/2010
    Posts
    86

    Re: Can a VBA run too fast?

    your code populate LastRow + 1
    So, instead of this -> Sheets("2012").Range("A" & LastRow & ":AO" & LastRow).Copy
    you should have -> Sheets("2012").Range("A" & LastRow + 1 & ":AO" & LastRow + 1).Copy
    Is this what you want?
    Boon

  4. #4
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Can a VBA run too fast?

    Hi Mike / Boon,

    Awesome advice as always guys, code is now working perfectly! Thank heaven for "excelforum" love this place! - Marco

+ 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