+ Reply to Thread
Results 1 to 6 of 6

Macro to rename sheet based on date in a cell with multiple occurrences.

  1. #1
    Registered User
    Join Date
    10-19-2010
    Location
    new mexico, US
    MS-Off Ver
    Excel 2007
    Posts
    14

    Macro to rename sheet based on date in a cell with multiple occurrences.

    Guys,

    I am getting whooped here.

    I have a spreadsheet that has 25 tabs. This worksheet updates based on an external data pull. I need to rename all the tabs in this sheet based on a date that is in cell C7 on each sheet.

    I have that part down with this code.

    Please Login or Register  to view this content.
    Now the problem that I have is that I may have the same date repeat 5 or 6 times in this data and need it to add a (2), (3), etc... to each extra one after the first. It is acceptable if it puts a (1) on the first one also.

    Anyone have any ideas?
    Last edited by timlocke; 04-09-2011 at 12:44 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro to rename sheet based on date in a cell with multiple occurrences.

    Try this
    Please Login or Register  to view this content.

    Hope this helps
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    10-19-2010
    Location
    new mexico, US
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Macro to rename sheet based on date in a cell with multiple occurrences.

    Doesn't quite work, I tried it in your sheet and in mine, it does the first one then gives me an error saying you cannot name the same as another sheet.

    It seems to be closer than what I had though.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro to rename sheet based on date in a cell with multiple occurrences.

    Try this then, I didn't allow for you running the macro more than once, is that what you meant by.
    ...I tried it in your sheet and in mine, it does the first one then gives me an error....
    Change the variable strRange to suit your reference cell
    Please Login or Register  to view this content.

    I have left a macro in this attachment that will reset the sheet names to "Sheet1", "Sheet2", "Sheet3", etc this should only be used after running the main macro.

    If this doesn't work post a sample workbook that contains the conditions met in your workbook.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-19-2010
    Location
    new mexico, US
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Macro to rename sheet based on date in a cell with multiple occurrences.

    This one works like a champ. I really appreciate all of your help. You have just saved me probably 2 to 3 hours a week.

  6. #6
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Macro to rename sheet based on date in a cell with multiple occurrences.

    Marcol,

    I was trying a similar query a few weeks back and this solution is very close to the one I required!..

    Thats a very good solution..!

    Warm Regards

    e4excel

+ 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