ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating sheet names in combobox (https://www.excelbanter.com/excel-programming/285938-populating-sheet-names-combobox.html)

Todd Huttenstine[_2_]

Populating sheet names in combobox
 
What is the code to display sheet names in a combobox? I
need it to display every sheet after Worksheets(4). This
means I need it to display the 5th sheet and beyond. If
there are only 4 sheets and no sheet5, then I need for
nothing to be displayed in the combobox.

Thanx

Todd Huttenstine

Tom Ogilvy

Populating sheet names in combobox
 
for i = 5 to sheets.count
listbox1.AddItem sheets(i).Name
Next

--
Regards,
Tom Ogilvy


Todd Huttenstine wrote in message
...
What is the code to display sheet names in a combobox? I
need it to display every sheet after Worksheets(4). This
means I need it to display the 5th sheet and beyond. If
there are only 4 sheets and no sheet5, then I need for
nothing to be displayed in the combobox.

Thanx

Todd Huttenstine




Todd Huttenstine[_2_]

Populating sheet names in combobox
 
Thank you

-----Original Message-----
for i = 5 to sheets.count
listbox1.AddItem sheets(i).Name
Next

--
Regards,
Tom Ogilvy


Todd Huttenstine

wrote in message
...
What is the code to display sheet names in a combobox?

I
need it to display every sheet after Worksheets(4).

This
means I need it to display the 5th sheet and beyond. If
there are only 4 sheets and no sheet5, then I need for
nothing to be displayed in the combobox.

Thanx

Todd Huttenstine



.


Chip Pearson

Populating sheet names in combobox
 
Todd,

Try something like the following:

Dim N As Long
With Me.ListBox1
.Clear
For N = 5 To ThisWorkbook.Worksheets.Count
.AddItem ThisWorkbook.Worksheets(N).Name
Next N
End With

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Todd Huttenstine" wrote in
message ...
What is the code to display sheet names in a combobox? I
need it to display every sheet after Worksheets(4). This
means I need it to display the 5th sheet and beyond. If
there are only 4 sheets and no sheet5, then I need for
nothing to be displayed in the combobox.

Thanx

Todd Huttenstine





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com