Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check Essbase option and return message | Excel Programming | |||
Pop up message for option Button | Excel Discussion (Misc queries) | |||
Change text for option buttons in message box | Excel Programming | |||
cell message with option buttons | Excel Programming | |||
Want to get user selections from a message box using option buttons | Excel Discussion (Misc queries) |