programatically reference controls on spreadsheet

K

k2sarah

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
 
C

Charles Chickering

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top