PC Review


Reply
Thread Tools Rate Thread

Add msgbox to confirm reset all

 
 
dgold82
Guest
Posts: n/a
 
      28th Jun 2009

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.
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      28th Jun 2009

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.

 
Reply With Quote
 
dgold82
Guest
Posts: n/a
 
      28th Jun 2009

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.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      28th Jun 2009

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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access Getting Started 8 20th Aug 2004 12:05 AM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access Forms 8 20th Aug 2004 12:05 AM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access 8 20th Aug 2004 12:05 AM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access Form Coding 8 20th Aug 2004 12:05 AM
Re: confirm msgbox in asp.net kong Microsoft ASP .NET 0 27th Aug 2003 02:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:01 AM.