Disabling MsgBox messages while running Call "Macro" function

marimar02

Board Regular
Joined
May 21, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm running several macros by using the Call "Macro Name" function. When I do, all Message Boxes that are written in those macros pop up and I have to click "Ok" each time to go to the next macro. How can I disable these.

Application.DisplayAlerts = False is not the code i'm looking for as I'm not looking to disable system messages but only those that are programmed into the macro.

Thank you...
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
keep cursor at the first line of the macro
hit edit-replace(control+H)

against "find what" type
msgbox
against "replace"
'msgbox
(single apostrophe in the beginning)
and click "replace all"
 
Upvote 0
Thanks for the reply venkat. I'm only looking to disable this when I run the Call macros. I still want the messages to pop up when running macros individually.
 
Upvote 0
A Public boolean variable, noMessageBoxes, could be set to True before calling the subs and set to False afterwards.
 
Upvote 0
Hmmm, that looked promising but didn't stop it

I set it as
Code:
public noMsgBox as Boolean
 
private sub CallAll()
 
noMsgBox = True
 
Call Macro1 'an example
Call Macro2
 
noMsgBox = False

Should I spell it out "noMessageBoxes" or what else am I doing wrong? All macro ran as normal and all messages still appeared.

Thanks for your help...
 
Upvote 0
You also need to alter Macro1 (and Macro2)
Note the second If block that returns the default from a multi-button MsgBox.
Code:
Sub Macro1()
   '...
   If Not noMsgBox Then
      MsgBox "simple Message"
   End If

   '...

   If Not noMsgBox Then
      userResponse = Msgbox("Yes or No", vbYesNo)
   Else
      userRespose = vbYes
   End If

   '...
End Sub
 
Upvote 0
You have to change each of the macros you are calling to have them look at the global variable and react if necessary. In each macro, where you now have this kind of line of code...

Code:
MsgBox "Something"
you will need to change it to this...

Code:
If Not noMsgBox Then MsgBox "Something"
where the Not is required because you are setting noMsgBox to True when you want the MessageBox skipped.
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top