Rockee,
To see them all, just take out the test for sh = Visible.
To exclude some, just test for them, like this
For Each sh In Worksheets
Select Case sh.Name
Case "Sheet1", "Sheet2"
Case Else: MsgBox sh.Name
End Select
Next sh
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Rockee052 " wrote in message
...
Hi,
Me again. I have created a userform with a listbox. I can view the
sheets with the following code:
Private Sub UserForm_Initialize()
Dim sh As Variant
For Each sh In ActiveWorkbook.Sheets
If sh.Visible = True Then
Me.ListBox1.AddItem sh.Name
End If
Next sh
With ListBox1
Value = ActiveSheet.Name
End With
End Sub
As you can tell I can only veiw the visible sheets. What would I need
to change to view all sheets? This is my goal, create 2 cmdbuttons,
View & Print. Each one does exactly what it says view: views the sheet
and if the sheet is hidden it will unhide the sheet, print: prints the
selected sheet only if it is visible. Also, would there be a way to
exclude some of my worksheets from showing up in the listbox. I have 28
sheets and would only like the user to be able to select 23 of the
sheets. 5 worksheets are for coding only. If anyone has some ideas or
suggestions, could you please show me the light... :) Right now VBA and
I are in a fight and VBA is winning.
Rockee
Excel 2003
---
Message posted from http://www.ExcelForum.com/