Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default CheckBox question

I have many, many, many check boxes on a worksheet. Under certain conditions
when the sheet is activated, I need to uncheck ALL the checkboxes. Without
naming each checkbox individually How can I do this in a loop?

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default CheckBox question

Try this

Dim CB As OLEObject

For Each CB In ActiveSheet.OLEObjects
If TypeName(CB) = "CheckBox" Then
CB.Object.Value = False
End If
Next CB

--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
I have many, many, many check boxes on a worksheet. Under certain

conditions
when the sheet is activated, I need to uncheck ALL the checkboxes.

Without
naming each checkbox individually How can I do this in a loop?

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default CheckBox question

Dave Peterson posted this

And if you used checkboxes from the Forms toolbar (on a worksheet):
ActiveSheet.CheckBoxes.Value = xlOn 'xlOff



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Juan Pablo González" wrote in message ...
Try this

Dim CB As OLEObject

For Each CB In ActiveSheet.OLEObjects
If TypeName(CB) = "CheckBox" Then
CB.Object.Value = False
End If
Next CB

--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
I have many, many, many check boxes on a worksheet. Under certain

conditions
when the sheet is activated, I need to uncheck ALL the checkboxes.

Without
naming each checkbox individually How can I do this in a loop?

thanks





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default CheckBox question

Both solutions offers did not work!

"Sheldon" wrote:

I have many, many, many check boxes on a worksheet. Under certain conditions
when the sheet is activated, I need to uncheck ALL the checkboxes. Without
naming each checkbox individually How can I do this in a loop?

thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default CheckBox question

Ok, I missed one thing in the previous code. This should work ok:

Sub Uncheck()
Dim CB As OLEObject

With Sheets("Sheet1")
For Each CB In .OLEObjects
If TypeName(CB.Object) = "CheckBox" Then
CB.Object.Value = False
End If
Next CB
End With
End Sub


--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
they were created using the Control Toolbox.
Sheldon

"Juan Pablo González" wrote:

Ok, which toolbar did you use to create the checkbox ?

--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
Both solutions offers did not work!

"Sheldon" wrote:

I have many, many, many check boxes on a worksheet. Under certain

conditions
when the sheet is activated, I need to uncheck ALL the checkboxes.

Without
naming each checkbox individually How can I do this in a loop?

thanks








  #6   Report Post  
Posted to microsoft.public.excel.programming
dtn dtn is offline
external usenet poster
 
Posts: 1
Default CheckBox question

Sir,

Can the same code be used if the checkboxes are on a userform?

Can similiar code be used for optionbuttons?

Thank you

dtn

"Juan Pablo González" wrote:

Ok, I missed one thing in the previous code. This should work ok:

Sub Uncheck()
Dim CB As OLEObject

With Sheets("Sheet1")
For Each CB In .OLEObjects
If TypeName(CB.Object) = "CheckBox" Then
CB.Object.Value = False
End If
Next CB
End With
End Sub


--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
they were created using the Control Toolbox.
Sheldon

"Juan Pablo González" wrote:

Ok, which toolbar did you use to create the checkbox ?

--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
Both solutions offers did not work!

"Sheldon" wrote:

I have many, many, many check boxes on a worksheet. Under certain
conditions
when the sheet is activated, I need to uncheck ALL the checkboxes.
Without
naming each checkbox individually How can I do this in a loop?

thanks






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default CheckBox question

'-----------------------------------------------------------------
Private Sub ClearCheckboxes()
'-----------------------------------------------------------------
Dim ctl As msforms.Control

For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"dtn" wrote in message
...
Sir,

Can the same code be used if the checkboxes are on a userform?

Can similiar code be used for optionbuttons?

Thank you

dtn

"Juan Pablo González" wrote:

Ok, I missed one thing in the previous code. This should work ok:

Sub Uncheck()
Dim CB As OLEObject

With Sheets("Sheet1")
For Each CB In .OLEObjects
If TypeName(CB.Object) = "CheckBox" Then
CB.Object.Value = False
End If
Next CB
End With
End Sub


--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
they were created using the Control Toolbox.
Sheldon

"Juan Pablo González" wrote:

Ok, which toolbar did you use to create the checkbox ?

--
Regards

Juan Pablo González

"Sheldon" wrote in message
...
Both solutions offers did not work!

"Sheldon" wrote:

I have many, many, many check boxes on a worksheet. Under

certain
conditions
when the sheet is activated, I need to uncheck ALL the

checkboxes.
Without
naming each checkbox individually How can I do this in a loop?

thanks








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox Question slow386 Excel Discussion (Misc queries) 7 July 21st 07 12:06 AM
Checkbox Question MCrum Excel Discussion (Misc queries) 1 January 15th 07 12:38 PM
Checkbox question Adam Kroger Excel Discussion (Misc queries) 0 December 19th 05 12:41 PM
quick question on a checkbox eluehmann[_2_] Excel Programming 0 September 24th 04 04:38 PM
CheckBox (unclicking) Question jordanctc[_18_] Excel Programming 0 September 20th 04 06:40 PM


All times are GMT +1. The time now is 11:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"