ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I want user to select the worksheet (https://www.excelbanter.com/excel-programming/419007-i-want-user-select-worksheet.html)

Mathieu

I want user to select the worksheet
 
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!
--
Mathieu

Per Jessen[_2_]

I want user to select the worksheet
 
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

On 24 Okt., 20:15, Mathieu wrote:
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!
--
Mathieu




All times are GMT +1. The time now is 04:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com