Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2017, 07:47 AM
JellehFish JellehFish is offline Run 1 of 2 Macros Depending on Y/N Response to Message Box Windows 7 64bit Run 1 of 2 Macros Depending on Y/N Response to Message Box Office 2010 64bit
Novice
Run 1 of 2 Macros Depending on Y/N Response to Message Box
 
Join Date: Jun 2017
Posts: 1
JellehFish is on a distinguished road
Default Run 1 of 2 Macros Depending on Y/N Response to Message Box

Hi,

I'm trying to write a macro that uses the MsgBox function to select which one of two macros should be run.

The actual macros themselves run fine, but trying to tie them together is proving difficult. I looked around online and couldn't find any clues, so this particular solution may not even be possible.

I have this macro which functions as I'd expect it to:

Sub MACRO()
If MsgBox("Run Macro A?", vbYesNo) = vbYes Then Macro A
End Sub

I want to add something to the effect of:



= vbNo Then Macro B

If I substitute the vbYes line for this vbNo line it runs as expected but can't get it to do both without prompting two message boxes.

It's so simple that I'm hoping there is an easy answer and I don't have to go about a completely different solution.

Any help is greatly appreciated.
Reply With Quote
  #2  
Old 06-15-2017, 09:08 AM
Souriane Souriane is offline Run 1 of 2 Macros Depending on Y/N Response to Message Box Windows 7 64bit Run 1 of 2 Macros Depending on Y/N Response to Message Box Office 2013
Advanced Beginner
 
Join Date: Feb 2017
Location: Quebec, Canada
Posts: 82
Souriane is on a distinguished road
Default

Hello!

Maybe somthing like that :

Code:
Sub MACRO()
If MsgBox("Run Macro A?", vbYesNo) = vbYes Then

Macro A

Else

Macro B

End If

End Sub
Bye!

Souriane
Reply With Quote
  #3  
Old 06-15-2017, 03:31 PM
gmaxey gmaxey is offline Run 1 of 2 Macros Depending on Y/N Response to Message Box Windows 7 32bit Run 1 of 2 Macros Depending on Y/N Response to Message Box Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

That way or:
Code:
Sub RunOneOrTheOther()
  Select Case MsgBox("Do you want to run Macro A?", vbQuestion + vbYesNo, "Run Macro")
    Case vbYes: A
    Case vbNo: B
  End Select
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: Very low response-rate! Jeff10 Office 6 12-17-2013 10:44 AM
Reply All in auto response Quackymacduck Outlook 0 10-12-2011 11:50 AM
Failing calendar response lucura Outlook 0 03-24-2011 01:01 AM
Run 1 of 2 Macros Depending on Y/N Response to Message Box appointments deleted from inbox upon response Roscoe Outlook 1 03-03-2010 12:15 PM
Unexpected Server Response GreenAccord Project 0 01-31-2006 12:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft