ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   mulitple checkboxes - changing value of all of them at once (https://www.excelbanter.com/excel-programming/337974-mulitple-checkboxes-changing-value-all-them-once.html)

Nathan

mulitple checkboxes - changing value of all of them at once
 
Hello,

I have mulitple checkbox controls (selected from the "control" toolbar) on
one worksheet. I would like to set the state of each checkbox to unchecked
all at once. I have figured out how to select all the checkboxes at one time
using:

ActiveSheet.OLEObjects.Select

But I cannot figure out how to change the value of all of them to "false".
I have tried, with no luck:

Selection.Value = false
Selection.oleobjects.Value = false
Selection.oleobjects.object.Value = false
etc
etc

Anyone how to do this?
Thanks.



Rowan[_2_]

mulitple checkboxes - changing value of all of them at once
 
I think you have to loop through them set them to false one at a time:

Sub UnCheck()
Dim ob As OLEObject
For Each ob In ActiveSheet.OLEObjects
If TypeName(ob.Object) = "CheckBox" Then
ob.Object.Value = False
End If
Next ob
End Sub


Hope this helps
Rowan

"nathan" wrote:

Hello,

I have mulitple checkbox controls (selected from the "control" toolbar) on
one worksheet. I would like to set the state of each checkbox to unchecked
all at once. I have figured out how to select all the checkboxes at one time
using:

ActiveSheet.OLEObjects.Select

But I cannot figure out how to change the value of all of them to "false".
I have tried, with no luck:

Selection.Value = false
Selection.oleobjects.Value = false
Selection.oleobjects.object.Value = false
etc
etc

Anyone how to do this?
Thanks.



Jim Cone

mulitple checkboxes - changing value of all of them at once
 
Worked for me...
Requires a project reference to Microsoft Forms 2.0 object library.
'-----------------------
Sub TurnThemOff()
Dim objCB As OLEObject
For Each objCB In ActiveSheet.OLEObjects
If TypeOf objCB.Object Is MSForms.CheckBox Then
objCB.Object.Value = False
End If
Next
Set objCB = Nothing
End Sub
'---------------------------

Jim Cone
San Francisco, USA


"nathan" wrote in message
...
Hello,
I have mulitple checkbox controls (selected from the "control" toolbar) on
one worksheet. I would like to set the state of each checkbox to unchecked
all at once. I have figured out how to select all the checkboxes at one time
using:
ActiveSheet.OLEObjects.Select
But I cannot figure out how to change the value of all of them to "false".
I have tried, with no luck:
Selection.Value = false
Selection.oleobjects.Value = false
Selection.oleobjects.object.Value = false
etc
etc
Anyone how to do this?
Thanks.



Nathan

mulitple checkboxes - changing value of all of them at once
 
That works, thanks to both of you.

"Jim Cone" wrote:

Worked for me...
Requires a project reference to Microsoft Forms 2.0 object library.
'-----------------------
Sub TurnThemOff()
Dim objCB As OLEObject
For Each objCB In ActiveSheet.OLEObjects
If TypeOf objCB.Object Is MSForms.CheckBox Then
objCB.Object.Value = False
End If
Next
Set objCB = Nothing
End Sub
'---------------------------

Jim Cone
San Francisco, USA


"nathan" wrote in message
...
Hello,
I have mulitple checkbox controls (selected from the "control" toolbar) on
one worksheet. I would like to set the state of each checkbox to unchecked
all at once. I have figured out how to select all the checkboxes at one time
using:
ActiveSheet.OLEObjects.Select
But I cannot figure out how to change the value of all of them to "false".
I have tried, with no luck:
Selection.Value = false
Selection.oleobjects.Value = false
Selection.oleobjects.object.Value = false
etc
etc
Anyone how to do this?
Thanks.





All times are GMT +1. The time now is 09:56 AM.

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