ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   clear checkbox (https://www.excelbanter.com/excel-programming/333658-clear-checkbox.html)

happyPotter

clear checkbox
 

I'm trying to complete a simple task. On my Transfer worksheet and on
my Delete worksheet, I have a command button called Clear and I would
like it to clear checkbox 3 and checkbox4 from the active sheet. I put
checks in checkbox 3 and checkbox4 and when I click the Clear button
nothing happens. The checkmarks are still there.
i tried this code but keeps giving me error "unable to get oleobjects
property of worksheet class"

'Worksheets("transfer").OLEObjects("CheckBox3").Ob ject.Value =
False

I also tried and still it doesn't work for me

checkbox3 = 0
checkbox3.value = false


I'm using excel 97.



Sub Button20_Click()

'worksheet Transfer clear

Worksheets("transfer").Select
CheckBox3 = False
CheckBox4 = False

end


--
happyPotter
------------------------------------------------------------------------
happyPotter's Profile: http://www.excelforum.com/member.php...fo&userid=1510
View this thread: http://www.excelforum.com/showthread...hreadid=384598


Ken Hudson

clear checkbox
 
I found this code in a Ron de Bruin message. Give it a try.
(It will set all checkboxes to False.)

Option Explicit
Dim obj
Sub ClearBox()
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
obj.Object.Value = False
End If
Next
End Sub
--
Ken Hudson


"happyPotter" wrote:


I'm trying to complete a simple task. On my Transfer worksheet and on
my Delete worksheet, I have a command button called Clear and I would
like it to clear checkbox 3 and checkbox4 from the active sheet. I put
checks in checkbox 3 and checkbox4 and when I click the Clear button
nothing happens. The checkmarks are still there.
i tried this code but keeps giving me error "unable to get oleobjects
property of worksheet class"

'Worksheets("transfer").OLEObjects("CheckBox3").Ob ject.Value =
False

I also tried and still it doesn't work for me

checkbox3 = 0
checkbox3.value = false


I'm using excel 97.



Sub Button20_Click()

'worksheet Transfer clear

Worksheets("transfer").Select
CheckBox3 = False
CheckBox4 = False

end


--
happyPotter
------------------------------------------------------------------------
happyPotter's Profile: http://www.excelforum.com/member.php...fo&userid=1510
View this thread: http://www.excelforum.com/showthread...hreadid=384598




All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com