+ Reply to Thread
Results 1 to 10 of 10

Rename Tabs

  1. #1
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Rename Tabs

    Have 8 worksheets in workbook. xxx 1, xxx 2, xxx 3, xxx 4, zzz 1, zzz 2, zzz 3, zzz 4
    Need a macro to rename each, adding 4 to the number portion so they read xxx 5, xxx 6, etc.
    Thanks

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Rename Tabs

    Hi,
    Try this code.
    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Rename Tabs

    or maybe
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Rename Tabs

    If you did not get my note on the problem I encountered please let me know at [email protected]. I work during the day and only get in here late, but do have my email forwarded and could respond to it. While I may not get an opportunity to get in here and pick up / try other options until late, but it does not mean I don't have a real interest in solving the problem.
    Thanks for your help!!

  5. #5
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Rename Tabs

    Added the one line you suggested, but ended up with tabs now numbered in numeric sequence 1, 2, 3, 4, 5 etc.
    I have 4 work sheets XXX Wk 1, XXX Wk 2, XXX Wk 3, XXX Wk 4, and 4 sheets named YYY Wk 1, YYY Wk 2, YYY Wk 3, YYY Wk 4, and 4 worksheets named ZZZ Wk 1, ZZZ Wk 2, ZZZ Wk 3, ZZZ Wk 4. Want to advance the date every 4 weeks, so the ones now reading 1 become 5, if 2, 6, if 3, 7, if 4, 8. Then after 4 weeks the numbers again grow to Wks 9,10, 11 and12 and so on for a full year, with the last number being Wk 52.
    Thanks

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Rename Tabs

    now it seems understood
    try
    Please Login or Register  to view this content.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Rename Tabs

    Hi,

    Try this new code that will deal with a word then a space and 1 or 2 digit numbers.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Rename Tabs

    Sorry - posted to wrong solution
    Last edited by ILoveStMartin; 03-30-2013 at 12:10 AM. Reason: Attached to wrong solution

  9. #9
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Rename Tabs

    nilem - it worked - Perfect!
    Thank you so much
    I will mark it solved as soon as I tell other kind / nice person that was also working on task.
    Thanks again

  10. #10
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Rename Tabs

    MarvinP - Thanks for trying on this. I go a run time error 13 - type mismatch. Highlighted when I went to debug was the line NewNum = Right(NewName, 2) + 4
    One from nilem did work so I am going to mark it solved.
    here is the one that did work in case you are interested:
    Sub ert()
    Dim i&, wsh As Worksheet, s$
    With CreateObject("vbscript.regexp")
    .Pattern = "\d+"
    For Each wsh In ThisWorkbook.Worksheets
    s = wsh.Name
    If .test(s) Then wsh.Name = .Replace(s, .Execute(s)(0) + 4)
    Next
    End With
    End Sub
    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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