+ Reply to Thread
Results 1 to 8 of 8

Add a new sheet and rename tab with a date

  1. #1
    Registered User
    Join Date
    07-07-2014
    Location
    Keighley, England
    MS-Off Ver
    2010
    Posts
    3

    Add a new sheet and rename tab with a date

    Hi

    I have a timesheet spreadsheet which I use to record the work I'm doing. Every week I create a new sheet. I have created a macro that automatically copies the sheet "Wk End 4 Jul" and clears the content, but I would like it to name the tab using the following format "Wk End d mmm" where the d mmm represents the Friday of the week which I'm creating it for. Can anybody advise how I adapt my exisiting macro to add this functionality as you will see I intitiate the macro with Ctrl+Shift+N:

    Sub NewSheet()
    ' NewSheet Macro
    ' Creates a new sheet
    ' Keyboard Shortcut: Ctrl+Shift+N
    Sheets("Wk End 4 Jul").Select
    Sheets("Wk End 4 Jul").Copy After:=Sheets(13)
    Sheets("Wk End 4 Jul (2)").Select
    Sheets("Wk End 4 Jul (2)").Name = "Wk End d mmm"
    Range("B4:D92").Select
    Selection.ClearContents
    Range("G4:H57").Select
    Selection.ClearContents
    Range("L4:L92").Select
    Selection.ClearContents
    Range("E91:F91").Select
    Selection.AutoFill Destination:=Range("E4:F91"), Type:=xlFillDefault
    Range("C4").Select

    End Sub

    I suspect there is an issue with the above code in that it puts the new sheet "After" the 4 Jul sheet which is fine for this weeks tab (11 Jul) but will mean that the 18 Jul tab will be out of order.

    Thanks in advance.

    Chris

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a new sheet and rename tab with a date

    Please use code tags when posting. Maybe:

    Please Login or Register  to view this content.
    Assumes your tabs are created on a Monday.
    Last edited by JOHN H. DAVIS; 07-07-2014 at 09:04 AM.

  3. #3
    Registered User
    Join Date
    07-07-2014
    Location
    Keighley, England
    MS-Off Ver
    2010
    Posts
    3

    Re: Add a new sheet and rename tab with a date

    Brilliant, it works perfectly. Is it possible to to tweek the code so that it puts new sheet at the end an not next to the sheet the copy is based upon?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a new sheet and rename tab with a date

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-07-2014
    Location
    Keighley, England
    MS-Off Ver
    2010
    Posts
    3

    Re: Add a new sheet and rename tab with a date

    Thanks John, that works really well. Your help is appreciated.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a new sheet and rename tab with a date

    You're welcome. Glad to help out and thanks for the feedback.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a new sheet and rename tab with a date

    BTW Chris, If your problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a new sheet and rename tab with a date

    Chris:

    I noticed a potential problem so I made a modification:

    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)

Similar Threads

  1. Rename sheet with yesterdays date
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 02:59 AM
  2. Replies: 4
    Last Post: 08-16-2013, 04:10 AM
  3. copy master sheet and rename sheet with date format
    By peter renton in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 02:08 PM
  4. Macro to rename a sheet using a date.
    By acstellato in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2010, 06:13 PM
  5. Rename a sheet with a specific date
    By Mistweaver in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2009, 06:21 PM

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