making the check box uncheck when the worksheet activated

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
How can i make the all check boxes uncheck when the worksheet has been activated.
Cheers
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
Dim Arr As Variant
    Dim i As Integer
    Dim ws As Worksheet
    Dim obj As OLEObject
    Arr = Array("Sheet2", "Sheet3")
    For i = LBound(Arr) To UBound(Arr)
        Set ws = Worksheets(Arr(i))
        For Each obj In ws.OLEObjects
            If TypeName(obj.Object) = "CheckBox" Then
                obj.Object.Value = False
            End If
        Next obj
    Next i
 
Upvote 0
Are you sure you mean whenever the worksheet is activated? Even if the user accidentally clicks another tab and then click the original sheet's tab again? Assuming yes, and assuming you got your CheckBoxes from the Forms Toolbar, give this a try. Right click the name tab at the bottom of the worksheet containing your CheckBoxes, select "View Code" from the popup menu that appears, then copy/paste the following code into the code window that opened up...

Code:
Private Sub Worksheet_Activate()
  ActiveSheet.CheckBoxes.Value = 0
End Sub
 
Upvote 0
Are you sure you mean whenever the worksheet is activated? Even if the user accidentally clicks another tab and then click the original sheet's tab again? Assuming yes, and assuming you got your CheckBoxes from the Forms Toolbar, give this a try. Right click the name tab at the bottom of the worksheet containing your CheckBoxes, select "View Code" from the popup menu that appears, then copy/paste the following code into the code window that opened up...

Code:
Private Sub Worksheet_Activate()
  ActiveSheet.CheckBoxes.Value = 0
End Sub


Thanks for ur reply Rick,
Sorry about missunderstanding ,
Its simply the test file with 20 questions and the answers are in options with (a-b-c-d) which located on worksheet1 with total of 80 check boxes.If the user finishes the answers they submit it by command button...what i want, the check boxes will be uncheck for the next user.
Hope its clear.
Many thanks
 
Upvote 0
Code:
Dim oObj As OLEObject
    
    On Error Resume Next
    For Each oObj In ActiveSheet.OLEObjects
        If TypeName(oObj.Object) = "[B][COLOR=#ff0000]CheckBox[/COLOR][/B]" Then oObj.Object.Value = 0
    Next
    ActiveSheet.CheckBoxes = False

That was the answer of my question..
Thanks anyway.
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top