+ Reply to Thread
Results 1 to 13 of 13

Current code to cycle through sheets and copy values is very slow - can it be sped up?

  1. #1
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Current code to cycle through sheets and copy values is very slow - can it be sped up?

    Hi

    I have the following code that cycles through my workbook (currently has about 150 sheets so is very large) and copies certain values to my main sheet. It is extremely slow.

    I am wondering if there is a better and faster way to do this? I also update my workbook frequently so when I add a sheet, I need to run the code all over again, which is very frustrating. I am looking for a way to also just update based on the sheet I have just added?

    This is just one part of the code - it is repeated three more times however I cannot post here as it is too long!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    Change this at the beginning of your code
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Then add this just before the End Sub line
    Please Login or Register  to view this content.
    This should (in theory) speed it up a bit.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    I don't think it can be "sped-up" - maybe:

    Please Login or Register  to view this content.
    Last edited by xladept; 09-29-2017 at 02:23 PM. Reason: Bakerman Correction
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    I tried this code xladept but I can an error here:

    Please Login or Register  to view this content.
    The error is 'subscript out of range'?

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    Change this.

    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    thanks bakerman but now I get this error down the bottom:

    Please Login or Register  to view this content.
    which is: 'Next without for'

    I assume I need to re-order these at the end somehow?

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    You'll have to indent your code properly and find out where there's missing or misplaced something.

  8. #8
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    well, I have taken xladept's suggestion above so I am not exactly sure what's missing?

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    I went line by line through your code, unless I missed something the change should have worked

    But, with Bakerman's rearrangement the End With has to precede the Next j.

    I've edited the post
    Last edited by xladept; 09-29-2017 at 02:24 PM.

  10. #10
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    with the changes made, it appears to be working now. I will do some more testing.

    Thanks for your help

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    But, is it any quicker?

  12. #12
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    sorry, yes it is! About 3 times faster, so really appreciate your help thank you

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Current code to cycle through sheets and copy values is very slow - can it be sped up?

    Good to know.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA code help (current code too slow and freezes)
    By xxsinghxx in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-13-2017, 05:22 PM
  2. Code to copy values to formula's in other sheets
    By Miehjs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-03-2015, 07:50 PM
  3. Code Sheets.Delete very slow
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-27-2014, 10:11 PM
  4. VBA Code to Move and/or Copy Sheets out to a New Workbook based on Cell Values
    By lhickerson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2014, 09:45 AM
  5. Copying values between sheets VERY slow...
    By ridetoeat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-22-2010, 04:35 AM
  6. VBA code to send data to different sheets slow refresh
    By covershaker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2010, 03:09 AM
  7. Cycle sheets & copy color coding
    By Hasseldm in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-24-2008, 10:14 AM

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