Results 1 to 3 of 3

Thread: Selecting Sheet via Input Box or other way

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    818
    Location
    well here is a method:

    Private Sub ListBox1_Click()
    Dim WS As Worksheet
    With Me.ListBox1
       Set WS = Worksheets(.List(.ListIndex))
       MsgBox "You selected - " & WS.Name
    End With
    WS.Select
    Set WS = Nothing
    End Sub
    
    Private Sub UserForm_Initialize()
    Dim WS As Worksheet
    Dim WB As Workbook
    Set WB = ThisWorkbook
    For Each WS In WB.Worksheets
       Me.ListBox1.AddItem WS.Name
       Next WS
       Set WS = Nothing
       Set WB = Nothing
    End Sub


    Create a form and add a Listbox to it and paste the code to it.
    Last edited by Aussiebear; 04-09-2023 at 04:42 PM. Reason: Adjusted the code tags

Posting Permissions

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