PDA

View Full Version : Populate Combobox with Worksheet Names EXCLUDE hidden



smartbuyer
11-28-2013, 04:37 PM
Hi

I have a code that shows all the sheet names in a workbook. How do I exclude the hidden sheets from the combobox list?


Private Sub Userform_Initialize()
Dim sht As Worksheet, txt As String

For Each sht In ActiveWorkbook.Sheets
Me.ComboBox1.AddItem sht.Name

Next sht
End Sub

mikerickson
11-28-2013, 05:13 PM
Try

Private Sub Userform_Initialize()
Dim sht As Worksheet, txt As String

For Each sht In ActiveWorkbook.Sheets
If sht.Visible = xlSheetVisible Then
Me.ComboBox1.AddItem sht.Name
End If
Next sht
End Sub

snb
11-29-2013, 02:18 AM
Private Sub Userform_Initialize()
For Each sh In Sheets
if sh.visible then c00=c00 & "|" & sh.name
Next

Combobox1.list=split(mid(c00,2),"|")
End Sub