+ Reply to Thread
Results 1 to 2 of 2

Cannot rename a sheet to same name error - Need code to override error

  1. #1
    Registered User
    Join Date
    08-25-2010
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    52

    Cannot rename a sheet to same name error - Need code to override error

    I have a multiselect GetOpenFilename code that opens all files, imports and creates a tab for each opened file. Sometimes I get duplicate files, but since there can be as much as 300 files, I simply cannot "scrub" the initial list to see if there is a duplicate.

    So, I need to either:

    HAVE the program to skip the duplicate and continue importing rest of the files
    OR
    HAVE the program to list all the files and tell me to delete any duplicates
    OR
    HAVE the program just override the existing sheetname with the duplicate
    OR
    whatever you guys might think would work - I'm open to ideas.

    Here is the code I use for importing the files:
    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Cannot rename a sheet to same name error - Need code to override error

    Hi,

    I implemented 4 different possibilities to handle this, please note that the code is not tested !

    Currently all options are enabled, to test which is best for you place comment signs (') to disable 3 of them and test one.

    Option 1: Add a counter to the sheetname, "SheetName_1"
    Option 2: Remove sheet with same name and replace it with the new one
    Option 3: Ask the user what to do, Skip or over
    Option 4: Skip the new sheet with the same name


    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

+ 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] error trapping for sheet rename
    By Xtopher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2013, 11:32 PM
  2. [SOLVED] 'Runtime Error 1004' when trying to Rename Worksheet using vba code
    By Raporter65 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 07:43 PM
  3. [SOLVED] Error message:Cannot rename a sheet to the same name as another sheet
    By AB33 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-12-2012, 11:14 AM
  4. Cannot rename a sheet error
    By yerromnitsuj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2011, 06:15 PM
  5. Object Error, Merge cells and Sheet rename.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-26-2011, 04:39 AM

Tags for this Thread

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