Locking CheckBoxes?

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
What is the vba code to lock all the checkboxes on the active worksheet?

I tried the following but not luck:
Code:
ActiveSheet.CheckBoxes = Locked

I am using Form Controls CheckBoxes not ActiveX checkBoxes.
 
How's this:

Code:
Sub foo()
   Dim sh As Shape
        For Each sh In ActiveSheet.Shapes
            sh.Locked = True
        Next sh
End Sub

HTH,
 
Upvote 0
Code:
    If ActiveSheet.CheckBoxes.Count > 0 Then
        ActiveSheet.CheckBoxes.Locked = True
    End If
 
Upvote 0
I was really looking for a way to lock the checkboxes so the user cannot check them. Didn't realize the locked property just prevents the user from moving the ceckboxes around.

Is there a way to do this?
 
Upvote 0
That seems to work on a test workbook but pulls an error when running on my actual workbook. The only thing I can think of is some of the checkboxes have there visible property set to false. Would I need to make them visible first then set the enable property?

If so is there a quick way to set all the checkboxes to visible = true
 
Upvote 0
Yes, you're right - the checkboxes must be visible first. So, if we put it all together we get:
Code:
    If ActiveSheet.CheckBoxes.Count > 0 Then
        ActiveSheet.CheckBoxes.Visible = True
        ActiveSheet.CheckBoxes.Enabled = False
    End If
You would also get an error if the activesheet is protected (with edit objects not checked).

Hope that helps...
 
Upvote 0
Cant figure out the problem. First I unprotect the ActiveSheet then run the following line:

Code:
ActiveSheet.CheckBoxes.Visible = True

Each time the script gets to this line I get a '1004' eror

Any ideas why this would happen?
 
Upvote 0
Is it preceded by a check that there are some checkboxes like I did in my code?
Code:
If ActiveSheet.CheckBoxes.Count > 0 Then
 
Upvote 0

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