ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox WorkSheet Trouble (https://www.excelbanter.com/excel-programming/357092-combobox-worksheet-trouble.html)

Beginner via OfficeKB.com

ComboBox WorkSheet Trouble
 
Hello

Im trying to add the name of each worksheet to a combobox but so far I'm
having little luck, I want it to be done in this style:

sub userform_initialize()

For x = 1 to 30

combobox1.additem sheet & x.name

next x

end sub

This can't be far out but it doesn't work, does anyone know how to do this

--
Message posted via http://www.officekb.com

Dave Peterson

ComboBox WorkSheet Trouble
 
sub userform_initialize()
dim x as long
For x = 1 to activeworkbook.sheets.count
combobox1.additem activeworkbook.sheets(x).name
next x
end sub

Or

sub userform_initialize()
dim wks as worksheet
For each wks in activeworkbook.worksheets
combobox1.additem wks.name
next wks
end sub

"Beginner via OfficeKB.com" wrote:

Hello

Im trying to add the name of each worksheet to a combobox but so far I'm
having little luck, I want it to be done in this style:

sub userform_initialize()

For x = 1 to 30

combobox1.additem sheet & x.name

next x

end sub

This can't be far out but it doesn't work, does anyone know how to do this

--
Message posted via http://www.officekb.com


--

Dave Peterson

Crowbar via OfficeKB.com

ComboBox WorkSheet Trouble
 
Excellent

Thanks Mate

--
Message posted via http://www.officekb.com


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

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