Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Add message box to confirm run macro

Anyone...I would like to add a message box to my code that will prompt the
user with a "Yes" or "No" to confirm running a macro when the user clicks the
command button. If YES, then the macro resumes; however, if NO, then the
macros stops.

Thanks in advance...Andy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Add message box to confirm run macro

One way:

Dim nResult As Long
nResult = MsgBox( _
Prompt:="Really run this macro?", _
Buttons:=vbYesNo)
If nResult = vbYes Then
'Rest of macro macro
MsgBox "OK"
End If



In article ,
Anolan wrote:

Anyone...I would like to add a message box to my code that will prompt the
user with a "Yes" or "No" to confirm running a macro when the user clicks the
command button. If YES, then the macro resumes; however, if NO, then the
macros stops.

Thanks in advance...Andy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Add message box to confirm run macro

I tried this and the macro still runs even when you select NO. can anyone
help. Thanks

"JE McGimpsey" wrote:

One way:

Dim nResult As Long
nResult = MsgBox( _
Prompt:="Really run this macro?", _
Buttons:=vbYesNo)
If nResult = vbYes Then
'Rest of macro macro
MsgBox "OK"
End If



In article ,
Anolan wrote:

Anyone...I would like to add a message box to my code that will prompt the
user with a "Yes" or "No" to confirm running a macro when the user clicks the
command button. If YES, then the macro resumes; however, if NO, then the
macros stops.

Thanks in advance...Andy


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Add message box to confirm run macro

Did you put the rest of your macro where I put

'Rest of macro

, i.e., within the If...End If structure?

Or are you saying that the Msgbox "OK" line was executed even if you
clicked NO??


In article ,
"Curt D." wrote:

I tried this and the macro still runs even when you select NO. can anyone
help. Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add message box to confirm run macro

I think J.E. hit the nail on the head. You didn't put your code in the correct
spot following his suggestion.

But maybe you could change the code just a bit:

Dim nResult As Long
nResult = MsgBox( _
Prompt:="Really run this macro?", _
Buttons:=vbYesNo)
If nResult = vbno Then
exit sub
End If

'rest of macro goes here now



Curt D. wrote:

I tried this and the macro still runs even when you select NO. can anyone
help. Thanks

"JE McGimpsey" wrote:

One way:

Dim nResult As Long
nResult = MsgBox( _
Prompt:="Really run this macro?", _
Buttons:=vbYesNo)
If nResult = vbYes Then
'Rest of macro macro
MsgBox "OK"
End If



In article ,
Anolan wrote:

Anyone...I would like to add a message box to my code that will prompt the
user with a "Yes" or "No" to confirm running a macro when the user clicks the
command button. If YES, then the macro resumes; however, if NO, then the
macros stops.

Thanks in advance...Andy



--

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
Confirm a choice before Macro JSnow Excel Discussion (Misc queries) 3 October 9th 08 08:00 PM
Macro confirm to run Neil R Excel Programming 2 November 19th 05 07:49 PM
Confirm Delete Message Disable RiosPapa New Users to Excel 2 October 7th 05 09:02 PM
Message box to confirm action CRayF Excel Programming 4 September 21st 05 01:03 AM
Macro : confirm Delete Tom Excel Programming 2 April 6th 04 09:50 AM


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

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

About Us

"It's about Microsoft Excel"