+ Reply to Thread
Results 1 to 3 of 3

"Find and Replace" in Sheet names

  1. #1

    "Find and Replace" in Sheet names

    Is there a way (with code perhaps) to search and replace sheet names?

    For example, I have 20 sheet names with "Direct (2)" in the name, and
    I'ld like to replace teh "Direct (2)" in the sheet name to "Net" in
    each instance.

    Thanks, Jim


  2. #2
    JE McGimpsey
    Guest

    Re: "Find and Replace" in Sheet names

    One way:

    Public Sub Direct2ToNet()
    Const sRepl As String = "Direct (2)"
    Dim ws As Worksheet
    Dim nPos
    On Error Resume Next
    For Each ws In ActiveWorkbook.Worksheets
    With ws
    If .Name Like "*" & sRepl & "*" Then _
    .Name = Replace(.Name, sRepl, "Net")
    End With
    Next ws
    On Error GoTo 0
    End Sub




    In article <[email protected]>,
    "[email protected]" <[email protected]> wrote:

    > Is there a way (with code perhaps) to search and replace sheet names?
    >
    > For example, I have 20 sheet names with "Direct (2)" in the name, and
    > I'ld like to replace teh "Direct (2)" in the sheet name to "Net" in
    > each instance.
    >
    > Thanks, Jim


  3. #3
    Brad Detchevery
    Guest

    Re: "Find and Replace" in Sheet names

    Example VBA Macro to play with.

    Hope this helps

    ....

    Sub Renamesheets()

    Dim S As Worksheet

    For Each S In ActiveWorkbook.Sheets
    V = InStr(1, S.Name, "Direct", vbTextCompare)
    If (V > 0) Then
    S.Name = "Net " + Mid(S.Name, V + 7, Len(S.Name))

    End If

    Next
    End Sub


    [email protected] wrote:
    > Is there a way (with code perhaps) to search and replace sheet names?
    >
    > For example, I have 20 sheet names with "Direct (2)" in the name, and
    > I'ld like to replace teh "Direct (2)" in the sheet name to "Net" in
    > each instance.
    >
    > Thanks, Jim
    >


+ 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