Consulting

Results 1 to 5 of 5

Thread: Find and replace tab names

  1. #1
    VBAX Regular
    Joined
    Dec 2010
    Posts
    8
    Location

    Find and replace tab names

    I have about 40 tabs and want to do a find and replace way to rename the tabs.

    Eg:
    Tab 1 = London Market Profile
    Tab 2 = London Market Profile Detail

    Change it to
    Tab 1 = London Service Profile
    Tab 2 = London Service Profile Detail

    How can I get a macro to just find and replace Market to Service on the tab names for 40 tabs?

    Thanks much!

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    [VBA]Sub blah()
    For Each Sht In ThisWorkbook.Sheets
    Sht.Name = Replace(Sht.Name, " Market ", " Service ")
    Next Sht
    End Sub
    [/VBA]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    try running this:
    [VBA]Sub change_sheet_name()
    Dim Sh As Worksheet
    For Each Sh In Sheets
    Sh.Name = Application.WorksheetFunction.Substitute(Sh.Name, "Market", "Service")
    Next Sh
    End Sub
    [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    @p45cal Lol!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Regular
    Joined
    Dec 2010
    Posts
    8
    Location
    Thanks Simon and P45Cal...this was super easy!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •