Reset radio buttons w/ protected worksheet

D

dgold82

I have a macro connected to a command button that clears all the radio
buttons on a worksheet. Only problem is when the worksheet is protected it no
longer works and gives me error #400. What do I need to do to clear
everything when locked? Here is my current code:

Sub ResetAll()
Dim OptBtn As OptionButton
With ActiveSheet
.Cells.Interior.ColorIndex = xlNone
For Each OptBtn In .OptionButtons
OptBtn.Value = False
Next OptBtn
End With
End Sub
 
N

Nigel

Try....

Sub ResetAll()
Dim OptBtn As OptionButton
With ActiveSheet
.Unprotect Password:="myPassword"
.Cells.Interior.ColorIndex = xlNone
For Each OptBtn In .OptionButtons
OptBtn.Value = False
Next OptBtn
.Protect Password:="myPassword"
End With
End Sub
 
D

dgold82

Thank you! Works perfectly.

Nigel said:
Try....

Sub ResetAll()
Dim OptBtn As OptionButton
With ActiveSheet
.Unprotect Password:="myPassword"
.Cells.Interior.ColorIndex = xlNone
For Each OptBtn In .OptionButtons
OptBtn.Value = False
Next OptBtn
.Protect Password:="myPassword"
End With
End Sub

--

Regards,
Nigel
(e-mail address removed)
 

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