Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Populate ComboBox with Worksheet Names

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Populate ComboBox with Worksheet Names

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Populate ComboBox with Worksheet Names

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Populate ComboBox with Worksheet Names

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Populate ComboBox with Worksheet Names

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listboxes - populate with all worksheet names bluegnu[_7_] Excel Programming 1 July 12th 06 02:19 PM
Populate Rows from worksheet Names. Trever B Excel Discussion (Misc queries) 2 May 15th 06 05:08 AM
Populate Combobox in VBA form from worksheet - Tricky Xispo[_9_] Excel Programming 1 November 16th 04 02:34 AM
populate combobox with sheet names David Goodall Excel Programming 3 September 12th 04 12:37 PM
populate combobox with sheet names David Goodall Excel Programming 0 September 12th 04 08:55 AM


All times are GMT +1. The time now is 11:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"