+ Reply to Thread
Results 1 to 10 of 10

Copying sheet stops if sheet name already exists

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    Tyler, Texas
    MS-Off Ver
    Excel 2003
    Posts
    5

    Copying sheet stops if sheet name already exists

    I have a workbook set up to keep a copy of every one of my purchase requisitions when i hit print. Everything works great except if the value of h51, which is the invoice number and what it names the new sheet is already used it pops an error and wants to debug. Is there a way to have it check for the same sheet name and add a number to the end of it to get by the error. Or any other suggestions would be helpful.

    Thanks

    Please Login or Register  to view this content.
    Last edited by Littrell; 04-25-2013 at 04:52 PM.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Copying sheet stops if sheet name already exists

    Please edit your post by placing code tags at the very beginning of your code and again at the end.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Copying sheet stops if sheet name already exists

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-25-2013
    Location
    Tyler, Texas
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Copying sheet stops if sheet name already exists

    Gives me run-time error '424'
    Object required

    Please Login or Register  to view this content.
    Last edited by Littrell; 04-25-2013 at 04:53 PM.

  5. #5
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Copying sheet stops if sheet name already exists

    PLEASE USE CODE TAGS! You agreed to use them when you signed up for the forum. If you are not sure how to use them, please access the FAQ's.

    When you receive the error and click debug, what is highlighted?

  6. #6
    Registered User
    Join Date
    04-25-2013
    Location
    Tyler, Texas
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Copying sheet stops if sheet name already exists

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Copying sheet stops if sheet name already exists

    Please upload a sample workbook.

  8. #8
    Registered User
    Join Date
    04-25-2013
    Location
    Tyler, Texas
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Copying sheet stops if sheet name already exists


  9. #9
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Copying sheet stops if sheet name already exists

    purchase requisition blank - ASRev.xls

    Notice in the attached how I ran it twice. The first time it created a new sheet named 123456. The second, because the same already existed, appended the new worksheet name to 123456z.

    Hope this helps.

  10. #10
    Registered User
    Join Date
    04-25-2013
    Location
    Tyler, Texas
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Copying sheet stops if sheet name already exists

    Thanks AlvaroSiza it works great.

+ 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