ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Forms combo box selection (https://www.excelbanter.com/excel-programming/430687-using-forms-combo-box-selection.html)

SundayGirl

Using Forms combo box selection
 
Hi

I have a form which displays all sheets in the workbook. I want the user to
be able to select the sheet(s) and click the button to open them. This is
my code so far.

Private Sub UserForm_Initialize()
Dim ws As Worksheet

For Each ws In Worksheets
With Me.LBView

.AddItem ws.Name
.List(.ListCount - 1, 1) = .RowSource

End With
Next ws

End Sub

Excel 2000

Thanks

Ruth




John

Using Forms combo box selection
 
If you add a button to your userform something like following should work.

Private Sub CommandButton1_Click()
Worksheets(Me.LBView.Text).Activate
End Sub
--
jb


"SundayGirl" wrote:

Hi

I have a form which displays all sheets in the workbook. I want the user to
be able to select the sheet(s) and click the button to open them. This is
my code so far.

Private Sub UserForm_Initialize()
Dim ws As Worksheet

For Each ws In Worksheets
With Me.LBView

.AddItem ws.Name
.List(.ListCount - 1, 1) = .RowSource

End With
Next ws

End Sub

Excel 2000

Thanks

Ruth






All times are GMT +1. The time now is 05:45 PM.

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