+ Reply to Thread
Results 1 to 6 of 6

Suggested End Sub/End With Error- look at last posting

  1. #1
    Registered User
    Join Date
    07-13-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Suggested End Sub/End With Error- look at last posting

    I recently recorded a macro that involves copying sheets and pasting them range valued in another workbook. After 26 pasted tabs, the macro gets "tired" and displays a debug message. I then have to save the template and copied files, close out of both, open both back up, go into the macro and set the next statement to start with the 26th tab. The macro then finishes fine. This happens with all of my recorded macros that run the same way.

    I was wondering if there was any way to write in code which could avoid this. I've tried a lot, but don't know a way to keep a macro running once the worksheet it is in is closed, which is necessary to refresh the macro.

    The code below is repeated for every sheet, just the cell it pulls from in the template and the place in pastes the copied sheet is changed

    Please Login or Register  to view this content.
    Any help is greatly appreciated and let me know if you need any more information from me!!

    Thanks
    Last edited by financeintern; 07-15-2010 at 10:14 AM. Reason: Corrected closing code tag

  2. #2
    Registered User
    Join Date
    07-13-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: "tired out" macro

    Sorry for the mixup, I edited my post. I'm not really sure what PM means so I am just replying to your message

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,343

    Re: Runtime error 9 in macro when copying sheets- Excel 2003

    Thanks for editing the title.

    The issue you have is a long-standing issue with Excel and copying entire sheets. My preferred solution is to add a new sheet and then copy the cells to it instead. Something like this (note I removed a bunch of unnecessary selecting and activating):
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: "tired out" macro

    Quote Originally Posted by financeintern View Post
    I'm not really sure what PM means
    PM means Private Message.
    In the message from RomperStomper; if you click his/her name in the upper left corner (next to his/her picture ), you should get a menu and one of the items is "Send a Private Message to...."
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  5. #5
    Registered User
    Join Date
    07-13-2010
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Runtime error 9 in macro when copying sheets- Excel 2003

    Edit: I changed my coding to the suggested one above (thanks for your help romperstomper), but now at the end of the code where my "End Sub" is, it is giving me an error message:

    "Suggested End With"

    however, when I change it to "End With" it gives me the error message:

    "Suggested End Sub"

    and when I add in both is gives me the suggested end sub again.

    I am starting to feel like I am in a Catch-22!!

    here is my last section of coding

    Please Login or Register  to view this content.
    Last edited by financeintern; 07-15-2010 at 10:12 AM.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,343

    Re: Runtime error 9 in macro when copying sheets- Excel 2003

    Sorry, I missed an End With:
    Please Login or Register  to view this content.

+ 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