Visible Sheet Showing When Hidden

  • Thread starter Thread starter Rockee052
  • Start date Start date
R

Rockee052

Hi,

I have some code for a listbox in a userform. Some of my sheets are se
to very hidden and with the code I have it's supposed to show just th
visible sheets. I have eight sheets that I dont want the users to hav
access to they are just used for coding purposes. But for some reaso
they show in the list box.

Thanks for any help or suggestions

Private Sub UserForm_Initialize()
Dim i As Long
With Me.ListBox1
.Clear
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
For i = 1 To ActiveWorkbook.Sheets.Count
If ActiveWorkbook.Sheets(i).Visible Then
.AddItem ActiveWorkbook.Sheets(i).Name
End If
Next
End With
End Sub

Rockee :confused
 
this
IF ActiveWorkbook.Sheets(i).Visible Then

should be
IF ActiveWorkbook.Sheets(i).Visible = xlSheetVisible Then
 
Back
Top