"If Yes then Proceed..." Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a simple Yes/No dialog box.
If the User clicks "Yes" it runs a macro that I have already recorded.
If "No" it closes the macro.

Is there a trusted public library of these types of basic macros somewhere?

Thanks so much.
 
Hi Bman342,

Try:

'=============>>
Public Sub Tester()
Dim res As VbMsgBoxResult

res = MsgBox(Prompt:="Do you wish to run the Macro?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbNo Then Exit Sub

'Your code

End Sub
'<<=============
 
dim vRep as Variant
vRep = Msgbox("Do you want to continue",vbYesNo)
if vRep = vbYes then
<do something>
end if

HTH
 
Hi Bman342,

Alternatively, try:

'=============>>
Public Sub Tester()
Dim res As VbMsgBoxResult

res = MsgBox(Prompt:="Do you wish to run the Macro?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbYes Then
Call myMacro
End If

End Sub
'<<=============
 
bman342 said:
I need a simple Yes/No dialog box.
If the User clicks "Yes" it runs a macro that I have already recorded.
If "No" it closes the macro.

Is there a trusted public library of these types of basic macros somewhere?

Thanks so much.


if MsgBox ("Message", vbYesNo) = vbYes then

.... macro

end if
 
bman342 said:
I need a simple Yes/No dialog box.
If the User clicks "Yes" it runs a macro that I have already recorded.
If "No" it closes the macro.

Is there a trusted public library of these types of basic macros somewhere?

Thanks so much.

Try This:

Msg = MsgBox("Your Question For User",vbYesNo,)
If Msg = vbNo Then Exist Sub
If Msg = vbYes Then Your Macro
 
Works fine. Much thanks to both.

Norman Jones said:
Hi Bman342,

Alternatively, try:

'=============>>
Public Sub Tester()
Dim res As VbMsgBoxResult

res = MsgBox(Prompt:="Do you wish to run the Macro?", _
Buttons:=vbYesNo + vbQuestion)

If res = vbYes Then
Call myMacro
End If

End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top