Populating combox with worksheet names

  • Thread starter Thread starter Martin Parker
  • Start date Start date
M

Martin Parker

Hi

I'm using the following to populate a combobox on a worksheet with the names
of all the worksheets in the workbook:-

Dim ws As Integer
With frmMenu.cbStartUpWorksheet
For ws = 1 To Sheets.Count
..AddItem Sheets(ws).Name
Next
End With

My question is I have one worksheet that is veryhidden and I dont want it to
show in the combobox. How do I do this?

Cheers
 
Use the .Visible property which list out xlSheetHidden, xlSheetVeryHidden and
xlSheetVisible....

Private Sub CommandButton1_Click()
Dim ws As Worksheet

With frmMenu.cbStartUpWorksheet
For Each ws In Worksheets
If ws.Visible <> xlSheetVeryHidden Then .AddItem ws.Name
Next
End With

End Sub
 
Thank you Jacob, worked great. I have slightly amended to code to only load
visible worksheets into the combobox.

Cheers
Martin
 
Back
Top