+ Reply to Thread
Results 1 to 3 of 3

renaming sheets where name reoccurs

  1. #1
    Registered User
    Join Date
    07-14-2010
    Location
    chelmsford, england
    MS-Off Ver
    Excel 2007
    Posts
    16

    renaming sheets where name reoccurs

    I am using a macro to rename a large number of spreedsheets according to the values in a particular couple of cells.

    Usually this works very well however recently i have encountered a problem with a bug occuring in the rare event that two sheets have the same cell value and hence the macro tries to give the sheet the same name as a previously named sheet.

    Can anyone think of a simple code i can use to, for example, tell excel to add a b onto the end of the sheet name if it has already occured (and then c if it happens to occur twice, then d, etc) whenever this happens?

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,607

    Re: renaming sheets where name reoccurs

    Perhaps you could do a check on the number of times the value occurs in the list using COUNTIF, and loop through adding a different suffix. What code are you using now?

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: renaming sheets where name reoccurs

    You could add a simple function to check if a sheet name exists:

    Please Login or Register  to view this content.
    Then call it in the following manner, where NewSheetName is the name you're trying to add:

    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