ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reset radio buttons w/ protected worksheet (https://www.excelbanter.com/excel-programming/427473-reset-radio-buttons-w-protected-worksheet.html)

dgold82

Reset radio buttons w/ protected worksheet
 
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

Nigel[_2_]

Reset radio buttons w/ protected worksheet
 
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




"dgold82" wrote in message
...
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



dgold82

Reset radio buttons w/ protected worksheet
 
Thank you! Works perfectly.

"Nigel" wrote:

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




"dgold82" wrote in message
...
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





All times are GMT +1. The time now is 10:05 PM.

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