ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Forms Option Buttons(Can be right mouse selected when sheet is loc (https://www.excelbanter.com/excel-discussion-misc-queries/130133-forms-option-buttons-can-right-mouse-selected-when-sheet-loc.html)

Newbeetle

Forms Option Buttons(Can be right mouse selected when sheet is loc
 
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.
--
This post was created using recycled electrons!

Dave Peterson

Forms Option Buttons(Can be right mouse selected when sheet is loc
 
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

Newbeetle wrote:

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.
--
This post was created using recycled electrons!


--

Dave Peterson

Newbeetle

Forms Option Buttons(Can be right mouse selected when sheet is
 
Cheers Dave,

You have been a life saver this week.
--
This post was created using recycled electrons!


"Dave Peterson" wrote:

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




All times are GMT +1. The time now is 02:53 PM.

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