ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   programatically reference controls on spreadsheet (https://www.excelbanter.com/excel-programming/376297-programatically-reference-controls-spreadsheet.html)

k2sarah

programatically reference controls on spreadsheet
 
i am trying to loop through all the controls on a spreadsheet and set certain
properites. In a userform, i am able to accomplish this with the following
code
~ for each control
~userform.controls("button"&i).caption="asdf"

however, i am at a lose as to how to loop through the controls placed
directly on a worksheet as opposed to the userform.

any help would be appreciated

thks


Charles Chickering

programatically reference controls on spreadsheet
 
Dim ctl as Object
For each ctl in ActiveSheet.Shapes
MsgBox ctl.Name
Next

This seems to work for both "Forms" Toolbar created Items and "Control
Toolbox" created items.
--
Charles Chickering

"A good example is twice the value of good advice."


"k2sarah" wrote:

i am trying to loop through all the controls on a spreadsheet and set certain
properites. In a userform, i am able to accomplish this with the following
code
~ for each control
~userform.controls("button"&i).caption="asdf"

however, i am at a lose as to how to loop through the controls placed
directly on a worksheet as opposed to the userform.

any help would be appreciated

thks


k2sarah

programatically reference controls on spreadsheet
 
Charles,

many thanks. With this method, i am having problems modifying the properties
of the 'toggle bar' for example the code me.ctl.caption="test"? any help
would be appreciated. thanks ken

"Charles Chickering" wrote:

Dim ctl as Object
For each ctl in ActiveSheet.Shapes
MsgBox ctl.Name
Next

This seems to work for both "Forms" Toolbar created Items and "Control
Toolbox" created items.
--
Charles Chickering

"A good example is twice the value of good advice."


"k2sarah" wrote:

i am trying to loop through all the controls on a spreadsheet and set certain
properites. In a userform, i am able to accomplish this with the following
code
~ for each control
~userform.controls("button"&i).caption="asdf"

however, i am at a lose as to how to loop through the controls placed
directly on a worksheet as opposed to the userform.

any help would be appreciated

thks



All times are GMT +1. The time now is 03:09 PM.

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