Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Clear All Check Boxes

I have a sheet of check boxes created using the Control Toolbox toolbar that
displays magazine subscriptions for employees. I'm looking for a command that
will automatically clear all the checkboxes on that sheet upon opening the
workbook. Rather than set each checkbox value to false, I'm sure there's an
easier way. Thanks!

--
Steve C
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Clear All Check Boxes

well, that's what you have to do, but you can do it quickly &
easily...........
call this routine from an auto-open sub......

Private Sub change_the_value()

Dim oControl As OLEObject
Dim ws As Worksheet

Set ws = ActiveSheet

For Each oControl In ws.OLEObjects

If TypeName(oControl.Object) = "Checkbox" Then
With oControl
.Value = False
End With

End If

Next oControl

End Sub

hope it works!
susan


On Mar 15, 3:07 pm, Steve C wrote:
I have a sheet of check boxes created using the Control Toolbox toolbar that
displays magazine subscriptions for employees. I'm looking for a command that
will automatically clear all the checkboxes on that sheet upon opening the
workbook. Rather than set each checkbox value to false, I'm sure there's an
easier way. Thanks!

--
Steve C



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Clear All Check Boxes

Hi, Susan:

The code wasn't working (when I stepped through it, it didn't recognize the
If test and kept looping). I did a slight modification, using "CheckBox"
instead of "Checkbox" and that helped.

However, when it gets to the line ".value = False", I get an error message
"Object doesn't support this property or method." Any other tweaks I can
make to the code that might help? Thanks! (below is my current code from
what you gave me):

Dim ws As Worksheet
Set ws = ActiveSheet

For Each oControl In ws.OLEObjects
' If TypeOf oControl.Object Is CheckBox Then
If TypeName(oControl.Object) = "CheckBox" Then
With oControl
.Value = False
End With
End If
Next oControl

--
Steve C


"Susan" wrote:

well, that's what you have to do, but you can do it quickly &
easily...........
call this routine from an auto-open sub......

Private Sub change_the_value()

Dim oControl As OLEObject
Dim ws As Worksheet

Set ws = ActiveSheet

For Each oControl In ws.OLEObjects

If TypeName(oControl.Object) = "Checkbox" Then
With oControl
.Value = False
End With

End If

Next oControl

End Sub

hope it works!
susan


On Mar 15, 3:07 pm, Steve C wrote:
I have a sheet of check boxes created using the Control Toolbox toolbar that
displays magazine subscriptions for employees. I'm looking for a command that
will automatically clear all the checkboxes on that sheet upon opening the
workbook. Rather than set each checkbox value to false, I'm sure there's an
easier way. Thanks!

--
Steve C




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Clear All Check Boxes

this was a quick modification of a sub i used for option buttons & i
didn't test it, so that's why i didn't get the CheckBox thing.

the other modification was changing
..Property
to
..Value
which i assumed would work fine, & apparently doesn't!

instead of
With oControl
.Value = False
End With


maybe try taking out the with........

ocontrol.value=false

or maybe you have to make it

set ocontrol.value=false

(i always get it mixed up if something's an object or not, so that's
one of the first fixes i try - either adding "set" or taking it out).
otherwise i don't know why it's erroring on that........
:/
sorry!
susan



On Mar 15, 3:57 pm, Steve C wrote:
Hi, Susan:

The code wasn't working (when I stepped through it, it didn't recognize the
If test and kept looping). I did a slight modification, using "CheckBox"
instead of "Checkbox" and that helped.

However, when it gets to the line ".value = False", I get an error message
"Object doesn't support this property or method." Any other tweaks I can
make to the code that might help? Thanks! (below is my current code from
what you gave me):

Dim ws As Worksheet
Set ws = ActiveSheet

For Each oControl In ws.OLEObjects
' If TypeOf oControl.Object Is CheckBox Then
If TypeName(oControl.Object) = "CheckBox" Then
With oControl
.Value = False
End With
End If
Next oControl

--
Steve C



"Susan" wrote:
well, that's what you have to do, but you can do it quickly &
easily...........
call this routine from an auto-open sub......


Private Sub change_the_value()


Dim oControl As OLEObject
Dim ws As Worksheet


Set ws = ActiveSheet


For Each oControl In ws.OLEObjects


If TypeName(oControl.Object) = "Checkbox" Then
With oControl
.Value = False
End With


End If


Next oControl


End Sub


hope it works!
susan


On Mar 15, 3:07 pm, Steve C wrote:
I have a sheet of check boxes created using the Control Toolbox toolbar that
displays magazine subscriptions for employees. I'm looking for a command that
will automatically clear all the checkboxes on that sheet upon opening the
workbook. Rather than set each checkbox value to false, I'm sure there's an
easier way. Thanks!


--
Steve C- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Clear All Check Boxes

Option Explicit
Sub auto_open()
Dim wks As Worksheet
Dim OLEObj As OLEObject

Set wks = Worksheets("sheet1")

For Each OLEObj In wks.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Then
OLEObj.Object.Value = False
End If
Next OLEObj
End Sub

Steve C wrote:

I have a sheet of check boxes created using the Control Toolbox toolbar that
displays magazine subscriptions for employees. I'm looking for a command that
will automatically clear all the checkboxes on that sheet upon opening the
workbook. Rather than set each checkbox value to false, I'm sure there's an
easier way. Thanks!

--
Steve C


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Clear All Check Boxes

Thanks, Dave. Your code did the trick. Thanks, Susan, for your help as well!
--
Steve C


"Dave Peterson" wrote:

Option Explicit
Sub auto_open()
Dim wks As Worksheet
Dim OLEObj As OLEObject

Set wks = Worksheets("sheet1")

For Each OLEObj In wks.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Then
OLEObj.Object.Value = False
End If
Next OLEObj
End Sub

Steve C wrote:

I have a sheet of check boxes created using the Control Toolbox toolbar that
displays magazine subscriptions for employees. I'm looking for a command that
will automatically clear all the checkboxes on that sheet upon opening the
workbook. Rather than set each checkbox value to false, I'm sure there's an
easier way. Thanks!

--
Steve C


--

Dave Peterson

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
Copy and move check box (check boxes) with new cell link? Marty Excel Worksheet Functions 1 January 20th 10 07:43 PM
How do I increase the size of check in check boxes Adams, Les Excel Discussion (Misc queries) 0 September 19th 06 02:35 PM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
How do i create a value for check boxes or option boxes Tim wr Excel Discussion (Misc queries) 1 February 9th 06 10:29 PM
Clear unactive combo boxes [email protected] Excel Programming 2 September 23rd 05 08:09 PM


All times are GMT +1. The time now is 04:57 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"