ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Message Box (https://www.excelbanter.com/excel-discussion-misc-queries/156836-message-box.html)

Ron (Bismark)

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.

JE McGimpsey

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.


Dave Peterson

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

Earl Kiosterud

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.




Ron (Bismark)

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.



Ron (Bismark)

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


Ron (Bismark)

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.





Dave Peterson

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

Tevuna

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


Dave Peterson

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

Tevuna

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


Dave Peterson

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


All times are GMT +1. The time now is 09:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com