ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping checkboxes embedded in worksheet (https://www.excelbanter.com/excel-programming/292761-looping-checkboxes-embedded-worksheet.html)

Theresa[_5_]

Looping checkboxes embedded in worksheet
 
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 a 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

Tom Ogilvy

Looping checkboxes embedded in worksheet
 
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

--
Regards,
Tom Ogilvy

"Theresa" wrote in message
om...
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 a 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





All times are GMT +1. The time now is 06:14 AM.

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