#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Message Box

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Message Box

One way:

Dim nResult As Long
nResult = Msgbox(Prompt:="Continue?", Buttons:=vbYesNo)
If nResult = vbYes Then
'Your code here
End If

Or, if you don't mind having multiple exit points to your macro:

Dim nResult As Long
nResult = Msgbox(Prompt:="Continue?", Buttons:=vbYesNo)
If nResult = vbNo then Exit Sub
'Your code here

In article ,
Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Message Box

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 611
Default Message Box

Ron,

If you won't be testing the yes/no response anywhere else, then you can shorten the code to:

If MsgBox("Continue?", vbYesNo, "Please answer this short question.") = vbYes Then
' Yes code goes here
MsgBox "Yes"
Else
' No code goes here
End
End If

--
Earl Kiosterud
www.smokeylake.com

Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
-----------------------------------------------------------------------
"Ron (Bismark)" wrote in message
...
I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Message Box

Thank you your info has helped me and saved me heaps of time. I had been
trying to achieve this for last two days. Very much appreciated.

"JE McGimpsey" wrote:

One way:

Dim nResult As Long
nResult = Msgbox(Prompt:="Continue?", Buttons:=vbYesNo)
If nResult = vbYes Then
'Your code here
End If

Or, if you don't mind having multiple exit points to your macro:

Dim nResult As Long
nResult = Msgbox(Prompt:="Continue?", Buttons:=vbYesNo)
If nResult = vbNo then Exit Sub
'Your code here

In article ,
Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Message Box

From the 3 replies I received yours was the one that was simplest for me to
follow and have used it. thankyou very much.

I would like to rate your response but can not see how I do this. Top Marks
from me.

"Dave Peterson" wrote:

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Message Box

Thankyou for your response. You have given me an additional option which will
help me on another project. Your quick response is very much apptreciated.

"Earl Kiosterud" wrote:

Ron,

If you won't be testing the yes/no response anywhere else, then you can shorten the code to:

If MsgBox("Continue?", vbYesNo, "Please answer this short question.") = vbYes Then
' Yes code goes here
MsgBox "Yes"
Else
' No code goes here
End
End If

--
Earl Kiosterud
www.smokeylake.com

Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
-----------------------------------------------------------------------
"Ron (Bismark)" wrote in message
...
I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.




  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Message Box

In a couple of hours/days/weeks..., you'll be able to look back and read each
response and see that they're pretty much equivalent.

It never hurts me (too much) to revisit things when I get a little smarter <bg.

Ron (Bismark) wrote:

From the 3 replies I received yours was the one that was simplest for me to
follow and have used it. thankyou very much.

I would like to rate your response but can not see how I do this. Top Marks
from me.

"Dave Peterson" wrote:

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 136
Default Message Box

Dave, What does this <bg tag mean?

"Dave Peterson" wrote:

In a couple of hours/days/weeks..., you'll be able to look back and read each
response and see that they're pretty much equivalent.

It never hurts me (too much) to revisit things when I get a little smarter <bg.

Ron (Bismark) wrote:

From the 3 replies I received yours was the one that was simplest for me to
follow and have used it. thankyou very much.

I would like to rate your response but can not see how I do this. Top Marks
from me.

"Dave Peterson" wrote:

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.

--

Dave Peterson


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Message Box

Big Grin.

Kind of like a smiley face in email messages.

Tevuna wrote:

Dave, What does this <bg tag mean?

"Dave Peterson" wrote:

In a couple of hours/days/weeks..., you'll be able to look back and read each
response and see that they're pretty much equivalent.

It never hurts me (too much) to revisit things when I get a little smarter <bg.

Ron (Bismark) wrote:

From the 3 replies I received yours was the one that was simplest for me to
follow and have used it. thankyou very much.

I would like to rate your response but can not see how I do this. Top Marks
from me.

"Dave Peterson" wrote:

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 136
Default Message Box

<bg"Learned something tonight"</bg

"Tevuna" wrote:

Dave, What does this <bg tag mean?

"Dave Peterson" wrote:

In a couple of hours/days/weeks..., you'll be able to look back and read each
response and see that they're pretty much equivalent.

It never hurts me (too much) to revisit things when I get a little smarter <bg.

Ron (Bismark) wrote:

From the 3 replies I received yours was the one that was simplest for me to
follow and have used it. thankyou very much.

I would like to rate your response but can not see how I do this. Top Marks
from me.

"Dave Peterson" wrote:

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.

--

Dave Peterson


--

Dave Peterson

  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Message Box

I don't speak the HTML <vbg.

http://www.acronymfinder.com



Tevuna wrote:

<bg"Learned something tonight"</bg

"Tevuna" wrote:

Dave, What does this <bg tag mean?

"Dave Peterson" wrote:

In a couple of hours/days/weeks..., you'll be able to look back and read each
response and see that they're pretty much equivalent.

It never hurts me (too much) to revisit things when I get a little smarter <bg.

Ron (Bismark) wrote:

From the 3 replies I received yours was the one that was simplest for me to
follow and have used it. thankyou very much.

I would like to rate your response but can not see how I do this. Top Marks
from me.

"Dave Peterson" wrote:

Dim Resp as long

......

Resp = msgbox(Prompt:="Want to continue?", buttons:=vbyesno)

if resp = vbno then
exit sub
end if

.....

Ron (Bismark) wrote:

I am trying to add a message box into a macro that will provide Yes / No
option. "Yes " to continue macro and "No" to end macro.

--

Dave Peterson


--

Dave Peterson


--

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
Pop up message HRlady Excel Worksheet Functions 1 April 22nd 07 10:14 PM
Message Box "Value" saziz Excel Discussion (Misc queries) 10 July 20th 05 03:58 AM
Message Box Greg Excel Discussion (Misc queries) 1 April 11th 05 05:01 PM
Add a Message Box Anthony Excel Worksheet Functions 2 February 25th 05 03:29 AM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM


All times are GMT +1. The time now is 05:59 AM.

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"