Hidden sheets in dialog

H

Hennie Neuhoff

Hi All,
I use the following code from which the user can select the relevant page
[sheet].
The workbook includes hidden[xlVeryHidden] sheets, which is also displayed but
can't be selected.
Any ideas [if it's possible??] to exclude hidden sheets from this code. [Xl
2003]

Public Sub Sheets_In_Dialog()

Dim J As Integer, N As Integer
Dim sName As String
Dim oSheet As Object
GetPage:
UserForm10.ListBox1.Clear
With UserForm10.ListBox1
For Each oSheet In Sheets
If TypeName(oSheet) = "Worksheet" Or _
TypeName(oSheet) = "Chart" Then
.AddItem oSheet.Name
End If
Next
End With

UserForm10.Show
N = UserForm10.ListBox1.ListIndex
With UserForm10.ListBox1
If .ListIndex = -1 Then
MsgBox ("No selection made")
GoTo GetPage
End If
End With

sName = UserForm10.ListBox1.Value
Set oSheet = Sheets(sName)
oSheet.Activate
Unload UserForm10
End Sub
 
T

Tim Williams

If (TypeName(oSheet) = "Worksheet" Or _
TypeName(oSheet) = "Chart") And _
oSheet.Visible<>xlSheetVeryHidden Then

.AddItem oSheet.Name

End If

Tim
 

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

Top