I want user to select the worksheet

M

Mathieu

Hi,

I want user to select the sheet he needs for a data selection. I am able to
se a form so they can chose the workbook, but I cannot figure out how to do
it for a worksheet. I am afraid they can be name differently.

Thanks!
 
P

Per Jessen

Hi Mathieu

With a listbox and a commandbutton on a form I thikn this can help
you:

Private Sub CommandButton1_Click()
SelectedWsh = Me.ListBox1.ListIndex
MsgString = Sheets(SelectedWsh + 1).Name & " was selected"
Msg = MsgBox(MsgString)
End Sub

Private Sub UserForm_Initialize()
Dim wb As Workbook
Set wb = ActiveWorkbook
For Each sh In wb.Sheets
Me.ListBox1.AddItem sh.Name
Next
End Sub

Regards,
Per
 
Top