Looping checkboxes embedded in worksheet

  • Thread starter Thread starter Theresa
  • Start date Start date
T

Theresa

Hello!

I'm new to programming in excel, so I'm hoping this is an "easy"
question. I have a worksheet with several checkboxes (from control
toolbox) and I want to loop through these and check if they are true
or false which then triggers more code. If their names are: box1,
box2, etc. can I use the loop to increment the 1, 2, 3.... Something
like:

for i = 1 to 10
if CheckBox & i. value = True then
code here
end if
next i

Thanks in advance for any help!

Theresa
 
Is the name box1 or checkbox1

Dim cBox as MsForms.CheckBox
for i = 1 to 10
set cBox = Activesheet.OleObjects("CheckBox" & i).Object
if cBox.Value then
' box is checked.

End if
Next i
 
Back
Top