Results 1 to 10 of 13

Thread: A Neat "Go To Sheet" Selector

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    It's simple to introduce the 'enter' selection method.
    I'ts also very easy to comment out the 'automatic selection' option:

    Code:
    Private Sub UserForm_Initialize()
        Left = Application.Left + (0.5 * Application.Width) - (0.5 * Width)
        Top = Application.Top + (0.5 * Application.Height) - (0.5 * Height)
      
        For Each sh In Sheets
          If sh.Visible Then ListBox1.Tag = ListBox1.Tag & "_" & sh.Name
        Next
    End Sub
    Private Sub UserForm_Activate()
        ListBox1.List = Split(Mid(ListBox1.Tag, 2), "_")
    End Sub
    
    Private Sub TextBox1_Change()
      ListBox1.List = Filter(Split(Mid(ListBox1.Tag, 2), "_"), TextBox1.Text)
      
      If ListBox1.ListCount = 1 Then M_select
    End Sub
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 40 And ListBox1.ListCount > 1 Then
            ListBox1.SetFocus
            ListBox1.ListIndex = 0
        End If
    End Sub
    
    Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 37 Then
           TextBox1.SetFocus
           ListBox1.ListIndex = -1
        ElseIf KeyCode = 13 Then
            M_select
        End If
    End Sub
    Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
      M_select
    End Sub
    
    Sub M_select()
        Sheets(ListBox1.List(ListBox1.ListIndex)).Activate
        Hide
    End Sub
    Attached Files Attached Files
    Last edited by snb; 06-06-2014 at 02:18 PM.

Similar Threads

  1. VBA Versions of my "Get Field" and "Get Reverse Field" formulas
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 4
    Last Post: 06-02-2017, 06:15 PM
  2. Reversing a "First Middle Last" Name to "Last, First Middle" Name Format
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 5
    Last Post: 01-06-2014, 10:04 PM
  3. Replies: 4
    Last Post: 09-09-2013, 05:13 PM
  4. Replies: 5
    Last Post: 04-18-2013, 02:30 AM
  5. Ordinal Suffix (i.e., "st", "nd", "rd" and "th")
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 0
    Last Post: 03-20-2012, 03:46 AM

Posting Permissions

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