ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   populate combobox with sheet names (https://www.excelbanter.com/excel-programming/309668-populate-combobox-sheet-names.html)

David Goodall

populate combobox with sheet names
 
Hello All
I'm trying to find a way to populate a combobox with the names of Worksheets
from one Workbook. I'm ok just adding sheets that already exist but I will
need to add more sheets to the workbook and the combobox needs to update
automatically. Each worksheet will have a unique name not just Sheet1, etc.

Any help is greatly appreciated.

Regards
David





David Goodall

populate combobox with sheet names
 
Apologies - I've partly solved my problem with

Dim mysheetlist As Worksheet

For Each mysheetlist In worksheets
Me.Cb1.AddItem mysheetlist.Name
Next mysheetlist

The only thing it doesn't do is update after I've added a new sheet. The
sheets are added programmically from the same userform.

Thanks
David

"David Goodall" wrote in message
...
Hello All
I'm trying to find a way to populate a combobox with the names of
Worksheets from one Workbook. I'm ok just adding sheets that already exist
but I will need to add more sheets to the workbook and the combobox needs
to update automatically. Each worksheet will have a unique name not just
Sheet1, etc.

Any help is greatly appreciated.

Regards
David









Dave Peterson[_3_]

populate combobox with sheet names
 
Couldn't you just add the new sheet name to the list when you add it.

David Goodall wrote:

Apologies - I've partly solved my problem with

Dim mysheetlist As Worksheet

For Each mysheetlist In worksheets
Me.Cb1.AddItem mysheetlist.Name
Next mysheetlist

The only thing it doesn't do is update after I've added a new sheet. The
sheets are added programmically from the same userform.

Thanks
David

"David Goodall" wrote in message
...
Hello All
I'm trying to find a way to populate a combobox with the names of
Worksheets from one Workbook. I'm ok just adding sheets that already exist
but I will need to add more sheets to the workbook and the combobox needs
to update automatically. Each worksheet will have a unique name not just
Sheet1, etc.

Any help is greatly appreciated.

Regards
David






--

Dave Peterson


Dave Peterson[_3_]

populate combobox with sheet names
 
I used something like this and it worked ok:


Private Sub CommandButton1_Click()
Worksheets.Add
Me.CB1.AddItem ActiveSheet.Name
End Sub



David Goodall wrote:

Apologies - I've partly solved my problem with

Dim mysheetlist As Worksheet

For Each mysheetlist In worksheets
Me.Cb1.AddItem mysheetlist.Name
Next mysheetlist

The only thing it doesn't do is update after I've added a new sheet. The
sheets are added programmically from the same userform.

Thanks
David

"David Goodall" wrote in message
...
Hello All
I'm trying to find a way to populate a combobox with the names of
Worksheets from one Workbook. I'm ok just adding sheets that already exist
but I will need to add more sheets to the workbook and the combobox needs
to update automatically. Each worksheet will have a unique name not just
Sheet1, etc.

Any help is greatly appreciated.

Regards
David






--

Dave Peterson



All times are GMT +1. The time now is 09:15 AM.

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