PDA

View Full Version : Solved: Easiest way to check/uncheck all checkboxes?



mae0429
07-21-2008, 11:25 AM
Hi, I have this crossposted on Mr. Excel:
http://www.mrexcel.com/forum/showthread.php?t=331524

I've got an embedded chart on a worksheet and it has 24 checkboxes (control toolbox, not form) corresponding to different devices. How would I go about linking another checkbox to select or unselect all the boxes?

I know it could generally be something like:

Private Sub checkbox_Click()
Select Case checkbox.Value
Case True
Make all the other checkboxes true
Case False
Make all the other checkboxes false
End Select
End Sub


And how the heck do I refer to the checkboxes?!?:banghead:

Thanks!
-Matt

xld
07-21-2008, 11:45 AM
Private Sub CheckBox1_Click()
Dim obj As OLEObject

For Each obj In Me.OLEObjects

If TypeName(obj.Object) = "CheckBox" Then

If obj.Name <> "CheckBox1" Then

obj.Object.Value = Me.CheckBox1.Value
End If
End If
Next obj
End Sub

mae0429
07-21-2008, 01:53 PM
Problem here is that, apparently, when using control toolbox checkboxes on an embedded chart, they are part of the Shapes collection.

mae0429
07-21-2008, 02:25 PM
Solved.


Sub MatchCheckbox()
Dim s As Shape
Dim i As Long
Worksheets("Chart").ChartObjects(1).Activate
With ActiveChart
For i = 8 To 31
.Shapes(i).ControlFormat.Value = .Shapes(32).ControlFormat.Value
Next i
End With
End Sub

xld
07-21-2008, 02:47 PM
Problem here is that, apparently, when using control toolbox checkboxes on an embedded chart, they are part of the Shapes collection.

And where did you mention an embedded chart?

mae0429
07-22-2008, 06:47 AM
From my first post:


I've got an embedded chart on a worksheet and it has 24 checkboxes (control toolbox, not form) corresponding to different devices.