+ Reply to Thread
Results 1 to 4 of 4

Thread: Running a macro within a macro with a message box

  1. #1
    Registered User
    Join Date
    02-08-2005
    Location
    Kent, UK
    MS-Off Ver
    2010
    Posts
    61

    Running a macro within a macro with a message box

    I have 4 macros that create 4 reports. I have a 5th macro that runs all 4 macros so creates all 4 reports if I need them all.

    All macros have a message box pop up to day they're complete. Of course this means the 5th "all reports" macro has 4 "I'm complete" message boxes".

    I really only want one message box to appear for the "all reports" macro. Is there a clever way to suppress the 4 individual messages boxes?

    If we could run more than one macro per button than it would be easy but of course we can't.

  2. #2
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Running a macro within a macro with a message box

    Why don't you use Excel's statusbar instead ?



  3. #3
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Running a macro within a macro with a message box

    One way:

    Sub Macro1(Optional blnShowMessage As Boolean = True)
    
    MsgBox "Running Macro 1"
    
    If blnShowMessage Then
        MsgBox "Macro 1 has completed"
    End If
    
    End Sub
    
    Sub Macro2(Optional blnShowMessage As Boolean = True)
    
    MsgBox "Running Macro 2"
    
    If blnShowMessage Then
        MsgBox "Macro 2 has completed"
    End If
    
    End Sub
    
    
    Sub Run_All_With_Message()
    
    Call Macro1
    Call Macro2
    
    End Sub
    
    Sub Run_All_Without_Message()
    
    Call Macro1(False)
    Call Macro2(False)
    
    End Sub

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Running a macro within a macro with a message box

    or
    Sub tst1()
       Application.DisplayAlerts = False
       tst2
       tst3
    End Sub
    
    Sub tst2()
      If Application.DisplayAlerts Then MsgBox "DisplayAlerts = true"
    End Sub
    
    Sub tst3()
      If Application.DisplayAlerts Then MsgBox "DisplayAlerts = true"
    End Sub



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0