![]() |
Add msgbox to confirm reset all
I have a command button that clears all the option buttons on a worksheet. I would like to add a message box that would ask the user to confirm they would like to clear all. They would then click OK or cancel. Here is my current code: Sub ResetAll() Dim OptBtn As OptionButton With ActiveSheet .Unprotect Password:="test" For Each OptBtn In .OptionButtons OptBtn.Value = False Next OptBtn .Protect Password:="test" End With End Sub Help would be much appreciated. Thanks. |
Add msgbox to confirm reset all
Try the below.. Sub ResetAll() Dim OptBtn As OptionButton If MsgBox("Reset all Option Buttons ?", vbYesNo + _ vbQuestion + vbDefaultButton2) = vbYes Then With ActiveSheet .Unprotect Password:="test" For Each OptBtn In .OptionButtons OptBtn.Value = False Next OptBtn .Protect Password:="test" End With End If End Sub If this post helps click Yes --------------- Jacob Skaria "dgold82" wrote: I have a command button that clears all the option buttons on a worksheet. I would like to add a message box that would ask the user to confirm they would like to clear all. They would then click OK or cancel. Here is my current code: Sub ResetAll() Dim OptBtn As OptionButton With ActiveSheet .Unprotect Password:="test" For Each OptBtn In .OptionButtons OptBtn.Value = False Next OptBtn .Protect Password:="test" End With End Sub Help would be much appreciated. Thanks. |
Add msgbox to confirm reset all
Perfect! Thanks. "Jacob Skaria" wrote: Try the below.. Sub ResetAll() Dim OptBtn As OptionButton If MsgBox("Reset all Option Buttons ?", vbYesNo + _ vbQuestion + vbDefaultButton2) = vbYes Then With ActiveSheet .Unprotect Password:="test" For Each OptBtn In .OptionButtons OptBtn.Value = False Next OptBtn .Protect Password:="test" End With End If End Sub If this post helps click Yes --------------- Jacob Skaria "dgold82" wrote: I have a command button that clears all the option buttons on a worksheet. I would like to add a message box that would ask the user to confirm they would like to clear all. They would then click OK or cancel. Here is my current code: Sub ResetAll() Dim OptBtn As OptionButton With ActiveSheet .Unprotect Password:="test" For Each OptBtn In .OptionButtons OptBtn.Value = False Next OptBtn .Protect Password:="test" End With End Sub Help would be much appreciated. Thanks. |
Add msgbox to confirm reset all
If the number of optionbuttons is not too large... Option Explicit Sub ResetAll() Dim resp As Long resp = MsgBox(Prompt:="Are you sure", Buttons:=vbYesNo) If resp = vbYes Then With ActiveSheet .Unprotect Password:="test" .OptionButtons.Value = False .Protect Password:="test" End With End If End Sub dgold82 wrote: I have a command button that clears all the option buttons on a worksheet. I would like to add a message box that would ask the user to confirm they would like to clear all. They would then click OK or cancel. Here is my current code: Sub ResetAll() Dim OptBtn As OptionButton With ActiveSheet .Unprotect Password:="test" For Each OptBtn In .OptionButtons OptBtn.Value = False Next OptBtn .Protect Password:="test" End With End Sub Help would be much appreciated. Thanks. -- Dave Peterson |
All times are GMT +1. The time now is 10:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com