VBA code for check boxes in a form

H

HKS

I created a form with 10 check boxes in Excel. The CheckBox name is index 1
to 10. Then, I wrote a For next statement in the VBA code to list the checked
CheckBox(s). However, I encounter problem at the below code (the macro will
not recognize the "CheckBox(X)"). Why?

For X = 1 To 9
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArraychoice(0 To Y)
vArraychoice(Y) = CheckBox(X).Caption
End If
Next X


Thanks,
HK
 
D

Dave Peterson

In a userform?

You could use:

if me.controls("Checkbox" & x).value = true then
 

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