Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Rick (MVP - Excel) "Allen" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Try this Private Sub UserForm_Initialize() For x = 1 To Worksheets.Count ComboBox1.AddItem Sheets(x).Name Next End Sub Mike "Allen" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That did the trick, thank you so much!
"Mike H" wrote: Hi, Try this Private Sub UserForm_Initialize() For x = 1 To Worksheets.Count ComboBox1.AddItem Sheets(x).Name Next End Sub Mike "Allen" wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your welcome and thanks for the feedback
"Allen" wrote: That did the trick, thank you so much! "Mike H" wrote: Hi, Try this Private Sub UserForm_Initialize() For x = 1 To Worksheets.Count ComboBox1.AddItem Sheets(x).Name Next End Sub Mike "Allen" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Listboxes - populate with all worksheet names | Excel Programming | |||
Populate Rows from worksheet Names. | Excel Discussion (Misc queries) | |||
Populate Combobox in VBA form from worksheet - Tricky | Excel Programming | |||
populate combobox with sheet names | Excel Programming | |||
populate combobox with sheet names | Excel Programming |