+ Reply to Thread
Results 1 to 11 of 11

Help with Optimizing Slow Working cut/paste data macro

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    Londonish, England
    MS-Off Ver
    Excel 2010
    Posts
    58

    Help with Optimizing Slow Working cut/paste data macro

    Hi All,

    I'm looking for a way to increase the speed of a macro I've already written. The concept is to change the format of a very large sales report into something that can be manipulated into a pivot table.

    The below code does work, but it runs rather slowly on the actual report I'm using it on at work (which is > 150k lines), so wondered if maybe there was a better way of doing it. I had considered an array, but after researching I am unsure how I would write the specific array values that I need, which are essentially always the 8 rows beneath the start row.

    Essentially this macro cuts rows and transplants them onto a parent row which is linked to the account number. I have attached a before and after spreadsheet, as hopefully that will show you what I'm trying to achieve.

    Here is the code:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,841

    Re: Help with Optimizing Slow Working cut/paste data macro

    See if this makes a difference. Change the sheet name (in red) to suit your needs.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    08-20-2012
    Location
    Londonish, England
    MS-Off Ver
    Excel 2010
    Posts
    58
    Quote Originally Posted by Mumps1 View Post
    See if this makes a difference. Change the sheet name (in red) to suit your needs.
    Please Login or Register  to view this content.
    Thanks! I'll give this a try tomorrow

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

    Re: Help with Optimizing Slow Working cut/paste data macro

    @ Chriz

    Please don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    For normal conversational replies, try using the QUICK REPLY box below.
    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.

  5. #5
    Registered User
    Join Date
    08-20-2012
    Location
    Londonish, England
    MS-Off Ver
    Excel 2010
    Posts
    58

    Re: Help with Optimizing Slow Working cut/paste data macro

    Apologies for that.

  6. #6
    Registered User
    Join Date
    08-20-2012
    Location
    Londonish, England
    MS-Off Ver
    Excel 2010
    Posts
    58

    Re: Help with Optimizing Slow Working cut/paste data macro

    @Mumps1,

    Now that i've tested this program, I can confirm that it is MUCH faster, so thanks! But I have discovered an issue when I tried it out on live data here in the office, I've noted that on the first pass that the loop does, that it seems to repeat the "SALES" Data from 2018 multiple times, rather than having the correct figures copied over from Sales 2019, Returns 2017 - 2019 and Errors 2017 - 2019.

    If you've got time I'd be very grateful if you could take a look, hopefully it's something easy to fix. I don't think you would have noticed it as I rather stupidly copied the test data over and over again on the example I gave.

    Edit: I've added your macro to the attached, and changed the line of data that I can see is being repeated, if you run the 'Chriz' Macro on the attached file, you can see what I'm referring to.

    Thanks

    Chriz
    Attached Files Attached Files
    Last edited by Chriz; 03-04-2019 at 09:44 AM.

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,841

    Re: Help with Optimizing Slow Working cut/paste data macro

    Try:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-20-2012
    Location
    Londonish, England
    MS-Off Ver
    Excel 2010
    Posts
    58

    Re: Help with Optimizing Slow Working cut/paste data macro

    @Mumps1, Confirm it is working perfectly now! Many thanks for your help with this, it's taught me some very useful things that I can incorporate into future macros!

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,841

    Re: Help with Optimizing Slow Working cut/paste data macro

    You are very welcome. Out of curiosity, about how long did it take to run on the 150 k lines?

  10. #10
    Registered User
    Join Date
    08-20-2012
    Location
    Londonish, England
    MS-Off Ver
    Excel 2010
    Posts
    58

    Re: Help with Optimizing Slow Working cut/paste data macro

    Hi Mumps1, I didn't time it with a stopwatch, but it was no longer than 30 secs! My previous macro was taking at least 5-6 mins

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,841

    Re: Help with Optimizing Slow Working cut/paste data macro

    OK. Thanks for letting me 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] Macro working slow
    By khushboo# in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-13-2018, 07:20 AM
  2. Replies: 4
    Last Post: 09-08-2016, 11:13 AM
  3. [SOLVED] VBA Macro to copy/paste and mail some data, but it's not working!
    By nitozinho in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2016, 10:51 AM
  4. Macro working very slow in Excel 2007
    By kapil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-29-2012, 04:41 AM
  5. [SOLVED] Optimizing/speeding up a slow INDEX & SMALL function for retrieving multiple matches
    By lesoies in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-07-2012, 11:56 AM
  6. Slow Macro ? - Need Assistance in Optimizing Code
    By robby10 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-12-2010, 11:43 AM
  7. Optimizing Excel macro to find/replace with the list of data contained in the macro
    By Iceyburnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2008, 08:41 PM

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