Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Mar 2004
    Location
    London, Gtr London, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Search for sheet name (winXP, office 2003)

    I have a workbook with lots of sheets, each has a unique name. Can I search for the name of a worksheet, or part of a name? Using the Find... menu item fails to throw up sheet names. Any help gratefully accepted.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Search for sheet name (winXP, office 2003)

    As far as I know, there is no built-in support for searching sheet names. You can place the following macro in your Personal.xls workbook and assign it to a custom menu item or toolbar button:

    Sub FindSheet()
    Dim strName As String
    Dim wsh As Worksheet
    strName = InputBox("Enter part of the sheet name.")
    If strName = "" Then
    MsgBox "Please enter something.", vbInformation
    Exit Sub
    End If
    For Each wsh In Worksheets
    If wsh.Name Like "*" & strName & "*" Then
    wsh.Activate
    Exit Sub
    End If
    Next wsh
    MsgBox "No sheet found.", vbExclamation
    End Sub

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Search for sheet name (winXP, office 2003)

    If you want Hans' code to not be case sensitive then you can modify the line to be (which is something I prefer):

    <pre>If UCase(wsh.Name) Like "*" & UCase(strName) & "*" Then</pre>


    Steve

  4. #4
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Las Vegas, Nevada, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Search for sheet name (winXP, office 2003)

    This might be a bit simplistic, but you can
    Richard Spring

Posting Permissions

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