View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
zackb[_2_] zackb[_2_] is offline
external usenet poster
 
Posts: 14
Default Worksheet Selection

Hi Gaz,

Sounds like you are wanting to use a UserForm. I'll assume this is correct
and you have these things installed on a UserForm:

Label, saying, "Choose Worksheets" (Label1)
ComboBox, will contain sheet names (ComboBox1)
CommandButton, saying, "OK" (CommandButton1)
CommandButton, saying, "Close" (CommandButton2)

Enter this code into your Userform ...


Option Explicit
Private Sub UserForm_Initialize()
Dim tmpWs As Worksheet, i#, n#, ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ws = ActiveSheet
Set tmpWs = Worksheets.Add(befo=Sheets(1))
For i = 2 To Worksheets.Count
tmpWs.Range("A" & i - 1) = Worksheets(i).Name
Next
tmpWs.Range("A1:A" & i - 2).Sort Key1:=Range("A1"), Header:=xlGuess
For n = 1 To i - 2
Me.ComboBox1.AddItem tmpWs.Range("A" & n).Text
Next
Me.ComboBox1.ListIndex = 0
tmpWs.Delete
ws.Activate
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton1_Click()
On Error GoTo errHandle
Worksheets(Me.ComboBox1.Value).Activate
Unload Me
Exit Sub
errHandle:
MsgBox "An error has occured!"
Resume
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub


--
Regards,
Zack Barresse, aka firefytr

"Gazza" wrote in message
...
Is it possible to set up a proceedure that will take a list of all the
worksheets in a workbook and produce a list of these alphabetically. This
list then to be used in such a way as when the user selects a particular
sheet name they are taken straight to that sheet.

Thanks

Gaz