+ Reply to Thread
Results 1 to 8 of 8

Changing Multiple sheet names by wk ending date for yr but need specific name/date format

  1. #1
    Registered User
    Join Date
    01-06-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Changing Multiple sheet names by wk ending date for yr but need specific name/date format

    I am new here so hopefully I will give you what you need. I have a 52 wk workbook for the year. I need to make a new workbook for 2013 and want to automatically rename the sheets based upon wk ending date. I have searched the forum for hours and found the following code:

    Sub YearWorkbook2()
    Dim iWeek As Integer
    Dim sht As Variant
    Dim sTemp As String
    Dim dSDate As Date

    sTemp = InputBox("Date for the first worksheet:", "End of Week?")
    dSDate = CDate(sTemp)

    Application.ScreenUpdating = False
    Worksheets.Add After:=Worksheets(Worksheets.Count), _
    Count:=(52 - Worksheets.Count)
    For Each sht In Worksheets
    sht.Name = Format(dSDate, "dd-mmm-yyyy")
    dSDate = dSDate + 7
    Next sht
    Application.ScreenUpdating = True
    End Sub


    It works to rename as "25-Jan-2013" but what I want the sheet name to be is "Wk 1/25/13", "Wk 2/1/13", and so on. I do not know how to modify the above code (if I even can) to achieve this result. Thanks for any help.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    Hi kedeling,

    Welcome to the forum!!

    As tab names can't have a forward or a backward slash, you can't have the tabs named in that format. You can, however, easily append "Wk" to the name if you like. Post back with another format and I'll see if I can code it for you.

    If you could also use the appropriate tags when posting code it would be appreciated.

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    01-06-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    Oh, you are right. My sheet names are "Wk 1-25-12", Wk 2-1-12", etc. Can you tell me how that is done?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    Try changing this line

    Please Login or Register  to view this content.
    In to

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-06-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    That works great for adding "Wk" but I am also trying to change the date format from "24-Jan-2013" to "1-24-13". Thanks for any help!

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-06-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    Thank you so much. Once you showed me how you tweaked the date format, I changed it a bit more to:
    Please Login or Register  to view this content.
    It worked great! Love this forum. If I did not post right I am sorry. Karen

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Changing Multiple sheet names by wk ending date for yr but need specific name/date for

    Karen,
    Glad you have tweaked it!

    Those of us who live outside US will aways struggle with US dates and I am sure it is also true on the other side of the Atlantic with European Dates.

+ 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