Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Looping through ComboBoxes in a worksheet

I have a number of worksheets with combobox lists in them.
What I want to do is populate the comboboxes with items
listed in named ranges on a master worksheet but am not
sure how I would loop through each combobox on each
worksheet.

The code for populating I already have. I need to look at
each combobox on each sheet and if combobox is cbOne then
populate with items from list1, cb2 - list2 etc.

Something along the lines of:-

Dim sht as worksheet, cb as comboBox

For each sht in ActiveWorkbook
For each cb in sht.Controls 'controls collection
_ 'will not work here
'add list items
Next
Next


Can anyone help ??

regards,

TonyM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Looping through ComboBoxes in a worksheet

dim cb as MsForms.Combobox
dim ole as OleObject
dim sh as Worksheet
for each sh in ActiveWorkbook.Worksheets
for each ole in sh.OleObjects
if typeof ole.Object is MSForms.Combobox then
set cb = ole.Object
if cb.Name = "cb1" then

elseif cb.Name = "cb2" then

end if
end if
Next
Next

--
Regards,
Tom Ogilvy

"TonyM" wrote in message
...
I have a number of worksheets with combobox lists in them.
What I want to do is populate the comboboxes with items
listed in named ranges on a master worksheet but am not
sure how I would loop through each combobox on each
worksheet.

The code for populating I already have. I need to look at
each combobox on each sheet and if combobox is cbOne then
populate with items from list1, cb2 - list2 etc.

Something along the lines of:-

Dim sht as worksheet, cb as comboBox

For each sht in ActiveWorkbook
For each cb in sht.Controls 'controls collection
_ 'will not work here
'add list items
Next
Next


Can anyone help ??

regards,

TonyM



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Looping through ComboBoxes in a worksheet

excellent!

thanks, Tom

-----Original Message-----
dim cb as MsForms.Combobox
dim ole as OleObject
dim sh as Worksheet
for each sh in ActiveWorkbook.Worksheets
for each ole in sh.OleObjects
if typeof ole.Object is MSForms.Combobox then
set cb = ole.Object
if cb.Name = "cb1" then

elseif cb.Name = "cb2" then

end if
end if
Next
Next

--
Regards,
Tom Ogilvy

"TonyM" wrote in

message
...
I have a number of worksheets with combobox lists in

them.
What I want to do is populate the comboboxes with items
listed in named ranges on a master worksheet but am not
sure how I would loop through each combobox on each
worksheet.

The code for populating I already have. I need to look

at
each combobox on each sheet and if combobox is cbOne

then
populate with items from list1, cb2 - list2 etc.

Something along the lines of:-

Dim sht as worksheet, cb as comboBox

For each sht in ActiveWorkbook
For each cb in sht.Controls 'controls collection
_ 'will not work here
'add list items
Next
Next


Can anyone help ??

regards,

TonyM



.

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
Looping checkboxes embedded in worksheet Theresa[_5_] Excel Programming 1 February 27th 04 04:41 AM
Looping down list and each time copying to another worksheet mattri Excel Programming 2 February 16th 04 06:26 PM
Looping down list and each time copying to another worksheet Matthew Richards Excel Programming 0 February 16th 04 04:58 PM
building a text string while looping though a worksheet Phillips Excel Programming 4 December 10th 03 08:31 AM
Control ComboBoxes & Worksheet Protection ChrisF Excel Programming 1 November 5th 03 05:50 PM


All times are GMT +1. The time now is 05:51 AM.

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

About Us

"It's about Microsoft Excel"