VBA code for the Check Boxes in a form

H

HKS

I created 10 checkboxes in the Excel form. The name of the checkboxes are
"CheckBox1...10." Then, I wrote the below For next statement in the VBA to
list the checked checkboxes name, but I encounterred problem, why?

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


Thanks in advance
HKS
 
B

Bob Phillips

For X = 1 To 10
If CheckBox(X) = True Then
Y = Y + 1 'Array counter
ReDim Preserve vArrayItem(0 To Y)
vArrayItem(Y) = Controls("CheckBox" & X).Caption
End If
Next X
 
H

HKS

Using your suggestion, I modified one more line of code too.
if Controls("CheckBox" & X).value = true then

Thanks Bob!
 

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