View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Checkbox problem

It looks like you're mixing code for checkboxes from the Forms toolbar with code
for checkboxes from the control toolbox toolbar.

I'm guessing that this was not your intention.

That first line:
Worksheets("HojaBase").CheckBoxes.Value = xlOff
is for checkboxes from the Forms toolbar.

If those are what you're really using, try:
Worksheets("HojaBase").checkboxes("Check Box 6").Value = xlon

========

Unless you've renamed those Forms checkboxes, they'll have names like:
Check Box 1
Check Box 2
....
Check Box 99

The Checkboxes from the Control toolbox toolbar have names like:
Checkbox1
Checkbox2
....
Checkbox99

=============
If you're really using checkboxes from the control toolbox toolbar:

Option Explicit
Sub FiltrarBandas()
Dim OLEObj As OLEObject

For Each OLEObj In Worksheets("HojaBase").OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Then
If LCase(OLEObj.Name) = LCase("checkbox6") Then
OLEObj.Object.Value = True
Else
OLEObj.Object.Value = False
End If
End If
Next OLEObj
End Sub

japfvg wrote:

Hi all,

I have a problem, I'm trying to modify the visible property or the value in
a checkbox inside a worksheet through a macro; I found in the F1 help of MS
Excel the way to do this, my code is like this:

Sub FiltrarBandas()
Sheets("HojaBase").CheckBoxes.Value = xlOff
Worksheets("HojaBase").OLEObjects("CheckBox6").Val ue = True
End Sub

But Excel gives me the error 1004 that the OLEObjects property cannot be
called from the WorkSheet class.

Do anyone knows how can I modify the checkbox properties from a macro??

Thank you very much!!


--

Dave Peterson