ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I Group Form Check Boxes? (https://www.excelbanter.com/excel-programming/307769-can-i-group-form-check-boxes.html)

JK

Can I Group Form Check Boxes?
 
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




Tom Ogilvy

Can I Group Form Check Boxes?
 
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


--
Regards,
Tom Ogilvy

"JK" wrote in message news:MBpWc.34$6b.32@trnddc04...
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







All times are GMT +1. The time now is 02:47 PM.

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