Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Message box with Yes or No option

I want to my 2nd message box (is the policy mod # is correct) to have a Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Message box with Yes or No option

Try adding this

Dim PolicyMod as VBMsgBoxResult

PolicyMod = Msgbox("Is the Policy Mod # correct?", vbYesNo)

if PolicyMod = vbYes then
'Do execution for Yes
elseif PolicyMod = vbNo then
'Do stuff for No
end if

"Munchkin" wrote:

I want to my 2nd message box (is the policy mod # is correct) to have a Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Message box with Yes or No option

What's the code to stop running the macro? Sorry - I'm self taught at all
this, so I'm not up to par on codes as much as others here. I kind of am
learning as I go.



"Barb Reinhardt" wrote:

Try adding this

Dim PolicyMod as VBMsgBoxResult

PolicyMod = Msgbox("Is the Policy Mod # correct?", vbYesNo)

if PolicyMod = vbYes then
'Do execution for Yes
elseif PolicyMod = vbNo then
'Do stuff for No
end if

"Munchkin" wrote:

I want to my 2nd message box (is the policy mod # is correct) to have a Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Message box with Yes or No option

If you want to completely end execution, use END. If you want to exit the
current sub, use EXIT SUB.

"Munchkin" wrote:

What's the code to stop running the macro? Sorry - I'm self taught at all
this, so I'm not up to par on codes as much as others here. I kind of am
learning as I go.



"Barb Reinhardt" wrote:

Try adding this

Dim PolicyMod as VBMsgBoxResult

PolicyMod = Msgbox("Is the Policy Mod # correct?", vbYesNo)

if PolicyMod = vbYes then
'Do execution for Yes
elseif PolicyMod = vbNo then
'Do stuff for No
end if

"Munchkin" wrote:

I want to my 2nd message box (is the policy mod # is correct) to have a Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Message box with Yes or No option

The structure of what you want to do is this...

Response = MsgBox "Is the Policy Mod # correct?", vbYesNo
If Response = vbYes Then
' The user clicked the Yes button, so put your "Yes" code here
Else
' The user clicked the Yes button, so put your "No" code here
End If

Note that we must store the answer the user gives you in a variable (which I
called Response for this example) and then test the variable to see what it
is. VB defines some (many) constants that can be used for this purpose....
the vbYes constant contains the value that a Yes response from a Yes/No
MessageBox (note the 2nd argument on the MsgBox function call) returns and,
if you need to do the test in reverse, there is a vbNo constant the contains
the value a No response produces, so your If..Then test could be done
against that if need be.

--
Rick (MVP - Excel)


"Munchkin" wrote in message
...
I want to my 2nd message box (is the policy mod # is correct) to have a Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and
the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Message box with Yes or No option

Damn! I wrote the first line incorrectly! It is a function call and needs
parentheses...

Response = MsgBox("Is the Policy Mod # correct?", vbYesNo)
If Response = vbYes Then
' The user clicked the Yes button, so put your "Yes" code here
Else
' The user clicked the Yes button, so put your "No" code here
End If

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
The structure of what you want to do is this...

Response = MsgBox "Is the Policy Mod # correct?", vbYesNo
If Response = vbYes Then
' The user clicked the Yes button, so put your "Yes" code here
Else
' The user clicked the Yes button, so put your "No" code here
End If

Note that we must store the answer the user gives you in a variable (which
I called Response for this example) and then test the variable to see what
it is. VB defines some (many) constants that can be used for this
purpose.... the vbYes constant contains the value that a Yes response from
a Yes/No MessageBox (note the 2nd argument on the MsgBox function call)
returns and, if you need to do the test in reverse, there is a vbNo
constant the contains the value a No response produces, so your If..Then
test could be done against that if need be.

--
Rick (MVP - Excel)


"Munchkin" wrote in message
...
I want to my 2nd message box (is the policy mod # is correct) to have a
Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and
the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Message box with Yes or No option

Strictly speaking, you don't need to declare a variable:

If MsgBox("Yes or No", vbYesNo) = vbYes Then
MsgBox "You said Yes"
Else
MsgBox "You said No"
End If

but a variable sure makes it easier.

- Jon
-------
Advanced Excel Conference - June 17-18 2009 - Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html

Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Rick Rothstein" wrote in message
...
The structure of what you want to do is this...

Response = MsgBox "Is the Policy Mod # correct?", vbYesNo
If Response = vbYes Then
' The user clicked the Yes button, so put your "Yes" code here
Else
' The user clicked the Yes button, so put your "No" code here
End If

Note that we must store the answer the user gives you in a variable (which
I called Response for this example) and then test the variable to see what
it is. VB defines some (many) constants that can be used for this
purpose.... the vbYes constant contains the value that a Yes response from
a Yes/No MessageBox (note the 2nd argument on the MsgBox function call)
returns and, if you need to do the test in reverse, there is a vbNo
constant the contains the value a No response produces, so your If..Then
test could be done against that if need be.

--
Rick (MVP - Excel)


"Munchkin" wrote in message
...
I want to my 2nd message box (is the policy mod # is correct) to have a
Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and
the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Message box with Yes or No option

Strictly speaking, you don't need to declare a variable:

If MsgBox("Yes or No", vbYesNo) = vbYes Then
MsgBox "You said Yes"
Else
MsgBox "You said No"
End If

but a variable sure makes it easier.

- Jon
-------
Advanced Excel Conference - June 17-18 2009 - Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html

Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Rick Rothstein" wrote in message
...
The structure of what you want to do is this...

Response = MsgBox "Is the Policy Mod # correct?", vbYesNo
If Response = vbYes Then
' The user clicked the Yes button, so put your "Yes" code here
Else
' The user clicked the Yes button, so put your "No" code here
End If

Note that we must store the answer the user gives you in a variable (which
I called Response for this example) and then test the variable to see what
it is. VB defines some (many) constants that can be used for this
purpose.... the vbYes constant contains the value that a Yes response from
a Yes/No MessageBox (note the 2nd argument on the MsgBox function call)
returns and, if you need to do the test in reverse, there is a vbNo
constant the contains the value a No response produces, so your If..Then
test could be done against that if need be.

--
Rick (MVP - Excel)


"Munchkin" wrote in message
...
I want to my 2nd message box (is the policy mod # is correct) to have a
Yes
or No button - if yes is clicked, the macro proceeeds, if no is clicked
another message box should appear stateing "Find correct policy mod" and
the
macro should stop running.

How do I do this? Thanks!

MY MACRO:
If Len(Application.Trim(Range("E5"))) < 1 Then
MsgBox "You have not entered a policy name"
Exit Sub
End If
'MsgBox "go on "

MsgBox "Is the Policy Mod # correct?"




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
Check Essbase option and return message Nigel Excel Programming 0 February 2nd 09 05:56 PM
Pop up message for option Button Karissa Excel Discussion (Misc queries) 0 November 12th 08 04:00 PM
Change text for option buttons in message box JDaywalt Excel Programming 1 March 31st 08 05:28 PM
cell message with option buttons Rmagic[_8_] Excel Programming 0 November 18th 05 05:55 PM
Want to get user selections from a message box using option buttons Walt Excel Discussion (Misc queries) 1 November 4th 05 03:04 AM


All times are GMT +1. The time now is 04:00 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"