+ Reply to Thread
Results 1 to 8 of 8

Naming Sheets with the Date.

  1. #1
    Registered User
    Join Date
    06-12-2010
    Location
    Hereford, England
    MS-Off Ver
    Excel 2003
    Posts
    73

    Naming Sheets with the Date.

    Hi,

    I have a macro that automatically adds a sheet to a workbook, it then renames it with the Date using this code:-

    PHP Code: 
    ActiveSheet.Name Format(Date"DD-MM-YYYY"
    The problem I have is that I can only do this once a day otherwise I get an error because a worksheet already exists with the Date. Is there a way I can do this so that if a sheet with the same date already exists it will rename the new one "DD-MM-YYYY 2". So on and So forth.

    Thanks in Advance
    Last edited by Baziwan; 06-27-2010 at 02:13 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: Naming Sheets with the Date.

    Try this
    Please Login or Register  to view this content.

    Hope this helps
    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
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Naming Sheets with the Date.

    Hi
    Try this macro


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by contaminated; 06-27-2010 at 02:25 PM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Naming Sheets with the Date.

    Try

    Please Login or Register  to view this content.

  5. #5
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Naming Sheets with the Date.

    Bob Phillips
    I understand what "On Error GoTo Next" statement
    But how to understand "GoTo 0" and why to use two error handling option in one sub????

  6. #6
    Registered User
    Join Date
    06-12-2010
    Location
    Hereford, England
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Naming Sheets with the Date.

    Thanks alot for the swift responce Marcol!
    That works Fine.

  7. #7
    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: Naming Sheets with the Date.

    Contaminated

    Please Login or Register  to view this content.
    Cancels the error handler and prevents unwanted instruction being carried over to further code

  8. #8
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Naming Sheets with the Date.

    Thanks Marcol
    I just used "On Error GoTo 0" statement in previous code
    Great explanation... Better than in books...

+ 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