Can I Group Form Check Boxes?

  • Thread starter Thread starter JK
  • Start date Start date
J

JK

I have 90 checkboxes on a worksheet and a CmdBtn to clear the selections. Is
there a way to group the checkboxes so I can clear them in one simple
procedure? Or am I stuck having to list each checkbox separately in a
procedure like If Sheets("Sheet1).CheckBox1.Value=True Then
Sheets("Sheet1).CheckBox1.Value=False, etc.

Thank you.
Regards,
Jim Kobzeff
 
do you mean forms as in checkboxes from the forms toolbar (or do you mean
activeX checkboxes from the control toolbox toolbar also known as MSForms).

for the first

Activesheet.Checkboxes.Value = xloff

for the 2nd

for each ctrl in Worksheets("Sheet1").OleObjects
if typeof ctrl is MSforms.CheckBox then
set cb = ctrl.Object
cb.Value = False
end if
Next


But it sounds like you want to work on a subset of the checkboxes.

If so, I would use the topleftcell property test its location on the sheet
with the intersect method

if not intersect(ctrl.TopLeftCell, Range("A1:F20")) is nothing then
ctrl.object.Value = False
End if

you can use similar with the controls from the Forms toolbar

for each cb in Worksheets("Sheet1").Checkboxes
if not intersect(cb.TopLeftCell, Range("A1:F20")) is nothing then
cb.Value = xlOff
end if
Next
 

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