Populate ComboBox with Worksheet Names

  • Thread starter Thread starter Allen
  • Start date Start date
A

Allen

I'm trying to populate a combobox in a userform with the names of the
worksheets in my spreadsheet.

I'm guessing I'll just need to put it in a userform_initialize statement
with a For Each / Next loop, but am having trouble getting it to work.

Any syntax suggestions are much appreciated! Thanks
 
Assuming your ComboBox is named ComboBox2, give this code a try...

Dim X As Long
....
....
For X = 1 To Worksheets.Count
ComboBox1.AddItem Worksheets(X).Name
Next
 
Hi,

Try this

Private Sub UserForm_Initialize()
For x = 1 To Worksheets.Count
ComboBox1.AddItem Sheets(x).Name
Next
End Sub

Mike
 
That did the trick, thank you so much!


Mike H said:
Hi,

Try this

Private Sub UserForm_Initialize()
For x = 1 To Worksheets.Count
ComboBox1.AddItem Sheets(x).Name
Next
End Sub

Mike
 
Back
Top