I want user to select the worksheet

  • Thread starter Thread starter Mathieu
  • Start date Start date
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!
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top