+ Reply to Thread
Results 1 to 4 of 4

Rename a sheet with a specific date

Hybrid View

  1. #1
    Registered User
    Join Date
    11-20-2009
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    25

    Rename a sheet with a specific date

    I am trying to create a macro that will copy a sheet, move it to the end and rename it it with the next date of the value of the date in a particular cell.

    I can do the first part no problem, however I am stuck with naming the sheet with the date which is the next day from the date value in a cell.

    i.e. If the date value in A1 of the copied and moved sheet is 11 Nov 2009 I need the next sheet to be called 12 Nov 2009 in that format (dd mmm yyyy)

    I would be appreciative of any help offered.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Rename a sheet with a specific date

    Try (using Wks variable):

    Wks.Name = Format(Wks.Range("A1") + 1, "dd mmm yyyy")
    HTH
    Jason

  3. #3
    Registered User
    Join Date
    11-20-2009
    Location
    Cardiff
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Rename a sheet with a specific date

    Thanks for your time bud.

    I can't seem to get it to work. Here's the code.

    Sub Macro3()

    Dim WS As Worksheet, WB As Workbook

    Set WB = ActiveWorkbook
    Set WS = WB.ActiveSheet

    WS.Copy After:=Sheets(WB.Sheets.Count)
    WS.Name = Format(Wks.Range("A1") + 1, "dd mmm yyyy")

    End Sub

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Rename a sheet with a specific date

    In the future, please be sure to wrap your code on the [CODE] tags.

    See if this works for you:

    Sub Macro3()
    
        Dim WS As Worksheet, WB As Workbook
        
        Set WB = ActiveWorkbook
        Set WS = WB.ActiveSheet
        
        WS.Copy After:=Sheets(WB.Sheets.Count)
        ActiveSheet.Name = Format(ActiveSheet.Range("A1") + 1, "dd mmm yyyy")
        
    End Sub

+ 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