Yes or No MsgBox in VBA Macro

Grimm127

Board Regular
Joined
Aug 17, 2011
Messages
92
Hi all you wonderful Guru's,

I have a Macro with several calls within. How do I place a message box in before the last call to either yes run the last call or no to end the macro right there?

Call Macro1
Call Macro2
pop up a msg box yes or no to either continue to the next call or end the macro
Call Macro3

Thanks in advance
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

jon1315

New Member
Joined
Jun 16, 2020
Messages
45
Office Version
  1. 365
Platform
  1. Windows
Hi

How about something like:

Dim answer as string

Call Macro1
Call Macro2
Answer=(msgbox "Run macro 3?" ,vbyesno)

If answer=vbyes then
call macro 3
end if
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,023
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Call Macro1
Call Macro2
If MsgBox("do you want to continue?", vbYesNo) = vbNo Then Exit Sub
Call Macro3
 

jon1315

New Member
Joined
Jun 16, 2020
Messages
45
Office Version
  1. 365
Platform
  1. Windows
Hi

How about something like:

Dim answer as string

Call Macro1
Call Macro2
Answer=msgbox( "Run macro 3?" ,vbyesno)

If answer=vbyes then
call macro 3
end if


Don't know how to edit a post but my bracket was in the wrong place!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,023
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,823
Messages
5,544,533
Members
410,617
Latest member
niayuliawati
Top