Populating combox with worksheet names

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
 
J

Jacob Skaria

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
 
M

Martin Parker

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

Cheers
Martin
 

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