Forms Option Buttons(Can be right mouse selected when sheet is loc

N

Newbeetle

Hi

I have been using form option buttons rather than the ones from the command
toolbox as they have a better appearance on the screen.

The option buttons are not locked because I use the macro to clear them all
when the sheet gets used again.

Private Sub clear_Click()
Worksheets("sheet1").CheckBoxes.Value = xlOff
Worksheets("sheet1").OptionButtons.Value = xlOff
End Sub


If I lock the option buttons I get an run time error on running the macro!

But if I don't lock the option buttons you can still right mouse and select
them, which is also true for the forms checkbox.

I like to use the forms option buttons as the sheet gets printed and these
buttons look better compared to the option buttons from the command toolbox.

Is there a way to modify the macro so that it will work when the option
buttons are locked?

Hope that makes sense.
 
D

Dave Peterson

I think you have a couple of options.

1. When you protect the worksheet, allow the user (and your code to edit
objects). This option is near the bottom of the list in xl2002+. It's a
checkbox in earlier versions.

2. Add code that unprotects the worksheet, does the work, reprotects the
worksheet.

Private Sub clear_Click()
dim myPWD as string
myPWD = "hi"
with worksheets("sheet1")
.unprotect password:=myPWD
.CheckBoxes.Value = xlOff
.OptionButtons.Value = xlOff
.protect password:=mypwd
end with
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top