View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Trying to set Option button values in macro on protected sheets

Hi Damon,

Try:

Sub Tester()
Dim op As OptionButton
Const PWORD As String = "opensaysme" '<<===== CHANGE

Sheets("Sheet1").Unprotect password:=PWORD

Set op = ActiveSheet.OptionButtons("Option Button 4")

op.Value = xlOff

Sheets("Sheet1").Protect password:=PWORD

End Sub


---
Regards,
Norman


"Damon" wrote in message
...
ActiveSheet.Shapes("Option Button 4").Select
With Selection
.Value = xlOff
End With

Hi the above will set Option Button 4 to false as long as the sheet is
unprotected or the buttons themselves are unlocked but I would preffer
both
to be protected.

Is it possible to set the value of the option button without 'selecting'
it
first?

I have tried:-

ActiveSheet.Shapes("Option Button 4").Value = xlOff

Shapes("Option Button 4").Value = xlOff

OptionButton("Option Button 4").Value = xlOff

and many more with no success...

I know that Sheets can be locked and unlocked in macros but can the
password
be incorporated into the macro so that the user is not promted for it when
the macro unlocks a sheet?

I am using 2003 but the file needs to work in 97 too!

Thank you in advance

Damon