PC Review


Reply
Thread Tools Rate Thread

Clear All Check Boxes

 
 
=?Utf-8?B?U3RldmUgQw==?=
Guest
Posts: n/a
 
      15th Mar 2007
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
 
Reply With Quote
 
 
 
 
Susan
Guest
Posts: n/a
 
      15th Mar 2007
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 <Ste...@discussions.microsoft.com> 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



 
Reply With Quote
 
=?Utf-8?B?U3RldmUgQw==?=
Guest
Posts: n/a
 
      15th Mar 2007
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 <Ste...@discussions.microsoft.com> 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

>
>
>

 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      15th Mar 2007
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 <Ste...@discussions.microsoft.com> 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 <Ste...@discussions.microsoft.com> 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 -



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      15th Mar 2007
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 With Quote
 
=?Utf-8?B?U3RldmUgQw==?=
Guest
Posts: n/a
 
      15th Mar 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check and clear Multiple check boxes Dean Microsoft Excel Programming 4 1st Apr 2010 04:32 PM
Re: Clear check boxes? Dave Peterson Microsoft Excel Programming 0 1st Dec 2009 08:12 PM
RE: Clear check boxes? Geoff Microsoft Excel Programming 0 1st Dec 2009 08:09 PM
Clear check boxes? Geoff Microsoft Excel Programming 1 1st Dec 2009 07:14 PM
How do I clear all check boxes w/out manually unchecking boxes? =?Utf-8?B?VEo=?= Microsoft Access 12 25th Aug 2005 02:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:26 PM.