Discussion Locked

Excel/VBA - how list available sheets

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
This problem seems like it should be fairly easy but I can't seem to figure the code. I'm trying to populate a list box with the names of the available sheets in an active workbook. Can anyone help?

3 replies

by dklippert

Here's a piece of code from the forums:

Private Sub UserForm_Activate()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
lstWS.AddItem ws.Name
Next ws
End Sub

Private Sub lstWS_Click()
ActiveWorkbook.Worksheets(lstWS.Text).Activate
Unload Me
End Sub

This discussion is closed to new replies.