![]() |
How can I access control properties?
Hi,
I have a control (a list box) embedded in a worksheet. I'm trying to access properties and methods of this control from a sub in a module. I discovered that I can call ListBox1.AddItem from code IN THE SHEET but if the same code is in a module it gives me an error (in my case is "Variable not defined" since I used "option explicit"). Apparently the control is not recognised in a sub. How can I access control properties from within a module? Thank you. |
How can I access control properties?
Hi
You have to add a reference to the sheet (or userform) in which the listbox is embedded. Sheets("Sheet1").ListBox1.AddItem "Test" Hopes this helps. --- Per On 2 Feb., 17:12, Paolo Sardi wrote: Hi, I have a control (a list box) embedded in a worksheet. I'm trying to access properties and methods of this control from a sub in a module. I discovered that I can call ListBox1.AddItem from code IN THE SHEET but if the same code is in a module it gives me an error (in my case is "Variable not defined" since I used "option explicit"). Apparently the control is not recognised in a sub. How can I access control properties from within a module? Thank you. |
All times are GMT +1. The time now is 09:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com