#1   Report Post  
Posted to microsoft.public.excel.misc
Brisbane Rob
 
Posts: n/a
Default Uncheck check boxes


Option Explicit

I'm trying to enusure that all checkboxes are returned to unchecked
when the workbook opens. All the boxes are on one sheet and were from
the Forms menu. I was very kindly supplied with this code but it
doesn't seem to be working on my workbook. I assume I'm doing something
wrong but it's in the code sheet OK.

Can anyone give me a pointer as to where I'm going wrong?

Thanks


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

Set wks = Worksheets("sheet1")

If wks.CheckBoxes.Count 0 Then
wks.CheckBoxes.Value = xlOff
End If

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


--
Brisbane Rob
------------------------------------------------------------------------
Brisbane Rob's Profile: http://www.excelforum.com/member.php...o&userid=25096
View this thread: http://www.excelforum.com/showthread...hreadid=512611

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Uncheck check boxes

Sub auto_open()
Dim wks As Worksheet
Dim cb As CheckBox

Set wks = Worksheets("Sheet1")

For Each cb In wks.CheckBoxes
Value = xlOff
Next cb

End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Brisbane Rob"
wrote in message
...

Option Explicit

I'm trying to enusure that all checkboxes are returned to unchecked
when the workbook opens. All the boxes are on one sheet and were from
the Forms menu. I was very kindly supplied with this code but it
doesn't seem to be working on my workbook. I assume I'm doing something
wrong but it's in the code sheet OK.

Can anyone give me a pointer as to where I'm going wrong?

Thanks


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

Set wks = Worksheets("sheet1")

If wks.CheckBoxes.Count 0 Then
wks.CheckBoxes.Value = xlOff
End If

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


--
Brisbane Rob
------------------------------------------------------------------------
Brisbane Rob's Profile:

http://www.excelforum.com/member.php...o&userid=25096
View this thread: http://www.excelforum.com/showthread...hreadid=512611



  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Uncheck check boxes

If all your checkboxes were from the Forms toolbar, you don't need that second
half:

Sub auto_open()
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

If wks.CheckBoxes.Count 0 Then
wks.CheckBoxes.Value = xlOff
End If

End Sub

Unless you have an ungodly amount of checkboxes, this should get them unchecked
all at once.

If you do have that ungodly amount, then Bob's code will cycle through each one.

Brisbane Rob wrote:

Option Explicit

I'm trying to enusure that all checkboxes are returned to unchecked
when the workbook opens. All the boxes are on one sheet and were from
the Forms menu. I was very kindly supplied with this code but it
doesn't seem to be working on my workbook. I assume I'm doing something
wrong but it's in the code sheet OK.

Can anyone give me a pointer as to where I'm going wrong?

Thanks

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

Set wks = Worksheets("sheet1")

If wks.CheckBoxes.Count 0 Then
wks.CheckBoxes.Value = xlOff
End If

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

--
Brisbane Rob
------------------------------------------------------------------------
Brisbane Rob's Profile: http://www.excelforum.com/member.php...o&userid=25096
View this thread: http://www.excelforum.com/showthread...hreadid=512611


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
Brisbane Rob
 
Posts: n/a
Default Uncheck check boxes


Once again Bob, I'm indebted to you. Thanks.


--
Brisbane Rob
------------------------------------------------------------------------
Brisbane Rob's Profile: http://www.excelforum.com/member.php...o&userid=25096
View this thread: http://www.excelforum.com/showthread...hreadid=512611

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
Is there a way to add up check boxes strider11580 Excel Discussion (Misc queries) 2 January 24th 06 04:37 AM
Filtering by Check Boxes Eggtavius Excel Discussion (Misc queries) 2 January 18th 06 04:41 AM
Can you sort with check boxes? Q Excel Discussion (Misc queries) 3 November 10th 05 08:11 PM
check boxes - copy MarkT Excel Discussion (Misc queries) 2 October 20th 05 04:33 PM
Check boxes - when one box is checked, I want a 2nd box to auto ch Russell-stanely Excel Discussion (Misc queries) 2 July 1st 05 08:52 PM


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