1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

userform with 1 list box and 2 command buttons

Discussion in 'Business Applications' started by mrl, Dec 6, 2011.

Thread Status:
Not open for further replies.
  1. mrl

    mrl Thread Starter

    Joined:
    Aug 12, 2007
    Messages:
    340
    Hi,
    I have a userform with a list box that has the letters A to Z:
    With the following code which I shortened for clarity and space
    HTML:
    Private Sub ListBox1_Click()
    Select Case Me.ListBox1.Value
    Case Is = "A":
    Application.Goto Reference:="aaaa"
               ‘ this is the range name for A
      End Select
      Unload Me
    End Sub
    
    This has the cursor go to the selected range

    It also has a command button that has a caption of “PRINT” with the following code:
    HTML:
    Private Sub CommandButton1_Click()
    UserForm2.Show
    Unload Me
    End Sub
    
    Which brings up another userform which also has a list box with the letters A to Z with the following code which again I shorted for clarity and space:
    HTML:
    Private Sub ListBox1_Click()
    Select Case Me.ListBox1.Value
    Case Is = "A":
       ActiveSheet.PageSetup.PrintGridlines = False
    ActiveSheet.PrintOut From:1, To:=2, Copies:=1
        Range("A1").Select
      End Select
      Unload Me
    End Sub
    
    If I were to have only 1 user form with 1 list box (with the letters A to Z)
    And 2 command buttons (FIND and PRINT), what code would I use for the command buttons so that with a letter and PRINT selected, it would print what I want, or with a letter and FIND selected, the selected range would show.



    Mike
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1030015

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice