looping through controls

  • Thread starter Thread starter cmpcwil2
  • Start date Start date
C

cmpcwil2

Is there a way to loop through controls (e.g. vb checkBox) that are o
the worksheet. I know you can do this for the userForm as follows

For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "CheckBox" Then
MsgBox CheckBox.Text
End If
Next ctrl

Is this possible for an active worksheet
 
Hope this is what you are after.

Sub erm()

Dim mycntrl As OLEObject
Dim sht As Worksheet

Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects

MsgBox mycntrl.Name

Next mycntrl


End Sub


Pet
 
If they are forms toolbar checkboxes, then use

Dim ctrl As CheckBox
For Each ctrl In ActiveSheet.CheckBoxes
MsgBox ctrl.Name
Next ctrl


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

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

Back
Top