ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing to controls on a worksheet (https://www.excelbanter.com/excel-programming/276048-referencing-controls-worksheet.html)

John Nikolopoulos

Referencing to controls on a worksheet
 
A worksheet I made has a number of controls (10
ComboBoxes).
How can controls be referenced as a group ?
I tested the structure :
For each ctl in Activesheet.Controls
.....
Next
but it didn't work...
Is there any solution out there?
Thanks
John Nikolopoulos
Serres, GREECE

Tom Ogilvy

Referencing to controls on a worksheet
 
Assume these are comboboxes from the Control Toolbox Toolbar as opposed to
the Forms toolbar.
Dim OleObj as OleObject
Dim cbox as MSForms.Combobox
For each OleObj in ActiveSheet.OleObjects
if typeof OleObj is MSForms.Combobox then
set cbox = OleObj.Object
msgbox cbox.Name
End if
Next

--
Regards,
Tom Ogilvy


"John Nikolopoulos" wrote in message
...
A worksheet I made has a number of controls (10
ComboBoxes).
How can controls be referenced as a group ?
I tested the structure :
For each ctl in Activesheet.Controls
.....
Next
but it didn't work...
Is there any solution out there?
Thanks
John Nikolopoulos
Serres, GREECE




Tom Ogilvy

Referencing to controls on a worksheet
 
Yep, thanks for the catch:

Assume these are comboboxes from the Control Toolbox Toolbar as opposed to
the Forms toolbar.
Dim OleObj as OleObject
Dim cbox as MSForms.Combobox
For each OleObj in ActiveSheet.OleObjects
if typeof OleObj.Object is MSForms.Combobox then
set cbox = OleObj.Object
msgbox cbox.Name
End if
Next


--
Regards,
Tom Ogilvy


"Dave Peterson" wrote in message
...
I think Tom meant:

If TypeOf OleObj.Object Is MSForms.ComboBox Then
instead of
If TypeOf OleObj Is MSForms.ComboBox Then



Tom Ogilvy wrote:

Assume these are comboboxes from the Control Toolbox Toolbar as opposed

to
the Forms toolbar.
Dim OleObj as OleObject
Dim cbox as MSForms.Combobox
For each OleObj in ActiveSheet.OleObjects
if typeof OleObj is MSForms.Combobox then
set cbox = OleObj.Object
msgbox cbox.Name
End if
Next

--
Regards,
Tom Ogilvy

"John Nikolopoulos" wrote in message
...
A worksheet I made has a number of controls (10
ComboBoxes).
How can controls be referenced as a group ?
I tested the structure :
For each ctl in Activesheet.Controls
.....
Next
but it didn't work...
Is there any solution out there?
Thanks
John Nikolopoulos
Serres, GREECE


--

Dave Peterson




Ioannis Nikolopoulos

Referencing to controls on a worksheet
 

I would like to thank you for your instant reply.
It helps me a lot. Than you again.
sincerely Yours
John Nikolopoulos


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 12:07 AM.

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