View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default CheckBoxes: How to reset

#3. Auto_Open() in a general module will RUN with the workbook opens (assuming
that the user allows macros to run).

Dave Peterson wrote:

#1. Change Sheet1 to the name of your worksheet that has the checkboxes
or change
Set wks = Worksheets("sheet1")
to
set wks = activesheet

If you want to work against the currently activesheet.

#2. Yep. MSForms.Checkbox is correct

#3. Auto_Open() in a general module will open with the workbook opens (assuming
that the user allows macros to run).

Rob wrote:

Thanks Dave, but I get a "Subscript out of range" message at the line Set
wks = Worksheets("sheet1").
I note that the procedure says MSForms.CheckBox. Is that right if the
CheckBoxes are from the Control Toolbox?

Also, does the Sub auto_open() mean that as soon as the sheet is opened this
procedure will run?

Rob

"Dave Peterson" wrote in message
...
And if they're from the Control Toolbox toolbar:

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

Rob wrote:

I'd like to know the VBA code to set all CheckBoxes on a worksheet to
false.
I presume a loop would be required, but I can't get one to work.

Rob

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson