Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro confirm to run Neil R Excel Programming 2 November 19th 05 07:49 PM
Skipping confirm Greg[_19_] Excel Programming 2 February 22nd 05 01:02 PM
Confirm Autofilter off Chris Excel Programming 2 January 13th 05 07:13 PM
Confirm deletion dsan Excel Programming 1 April 19th 04 02:48 PM
Please confirm the following bug in Excel DennisE Excel Programming 3 December 22nd 03 05:38 PM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"