userform with 1 list box and 2 command buttons

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mrl

Thread Starter
Joined
Aug 12, 2007
Messages
348
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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top