+ Reply to Thread
Results 1 to 7 of 7

Deactive msgbox from other macroes when clicking "master" macro

  1. #1
    Registered User
    Join Date
    10-31-2016
    Location
    Melbourne
    MS-Off Ver
    13
    Posts
    33

    Deactive msgbox from other macroes when clicking "master" macro

    Hi there

    I have created a MasterDelete Macro, that will delete entries from all cells on multiple tabs. However, as I am simply "calling" the macros which delete the individual sheet entries, the msg box that I have added to each and every macro (DeleteEntriesServiceItems, DeleteIntroduction, DeleteAdditionalOnSiteEffort, DeleteTravel, DeleteSurcharges), comes up every time i run this MasterDelete Macro. So the user will have to click "Yes" 5 times before that MasterDelete Macro will have run through everything. How can I disable these msg boxes, while still "calling" the 5 macros? (Alternative would be to copy the codes of the other macros to the MasterDelete Macro without the msgbox).

    Thanks!!



    Sub MasterDelete()
    'will delete entries from alllllllll blue tabs

    Application.ScreenUpdating = False

    Dim admin_passwort As String
    admin_passwort = "Service_Admin"

    ActiveSheet.Unprotect password:="Service_Admin"

    Dim answer As Variant

    answer = MsgBox("Are you sure you want to delete all entries on all tabs?", vbYesNo + vbQuestion, "Delete user entries")

    If answer = vbYes Then

    Application.DisplayAlerts = False
    Worksheets("Service items").Visible = True
    Worksheets("Additional on-site effort").Visible = True
    Worksheets("Travel").Visible = True
    Worksheets("Surcharges").Visible = True

    Call DeleteEntriesServiceItems
    Call DeleteIntroduction
    Call DeleteAdditionalOnSiteEffort
    Call DeleteTravel
    Call DeleteSurcharges

    End If

    Application.DisplayAlerts = True

    Worksheets("Introduction").Select
    Range("A1").Select
    Application.ScreenUpdating = True

    End Sub

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Deactive msgbox from other macroes when clicking "master" macro

    What's the reason of "the msg box that I have added to each and every macro (DeleteEntriesServiceItems, DeleteIntroduction, DeleteAdditionalOnSiteEffort, DeleteTravel, DeleteSurcharges)"?
    Just remove those msgbox`es from each macro and user will be promted only once.

  3. #3
    Registered User
    Join Date
    10-31-2016
    Location
    Melbourne
    MS-Off Ver
    13
    Posts
    33

    Re: Deactive msgbox from other macroes when clicking "master" macro

    I added these, because they are "sub"macros for other sheets. There I also have a button that performs deleting the respective entries on the activesheet - hence I cannot remove the msgbox there because otherwerwise the user might be delete them by mistake when randomly clicking on the button on that tab.

    Thanks!

  4. #4
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Deactive msgbox from other macroes when clicking "master" macro

    Create duplicates of your Call macros but without the msgboxes for use only in the master macro

    Call MasterDeleteEntriesServiceItems
    Call MasterDeleteIntroduction
    Call MasterDeleteAdditionalOnSiteEffort
    Call MasterDeleteTravel
    Call MasterDeleteSurcharges

  5. #5
    Registered User
    Join Date
    10-31-2016
    Location
    Melbourne
    MS-Off Ver
    13
    Posts
    33

    Re: Deactive msgbox from other macroes when clicking "master" macro

    OK cool, that's a great input. Thanks!

  6. #6
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Deactive msgbox from other macroes when clicking "master" macro

    No problem StefaniaLa

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Deactive msgbox from other macroes when clicking "master" macro

    A better approach would be to edit the existing procedures so they take an optional parameter...

    Please Login or Register  to view this content.
    The optional parameter is defaulted to True and then add a check for the value of this parameter in the procedure code.
    Please Login or Register  to view this content.
    Your existing code to call the individual procedures will not change, but the master procedure code is changed slightly...

    Please Login or Register  to view this content.
    End result, one set of procedures that displays a message box if called from an 'individual' sub but does not display it when called from the master sub.

    (Typed freehand, untested but the principal is right even if the code isn't)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Master Summary sheet to "remember" formulae and not do "REF!" errors? (EXCEL 2003)
    By elizabethchilver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2016, 07:08 PM
  2. Macro for "Master" and "Child" products with image files
    By ddenicola in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2014, 08:30 AM
  3. [SOLVED] If Not ActiveSheet.Range("A1").Value Like "apple" Then MsgBox "Error"
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2014, 02:16 PM
  4. programming code in macro "to find other excel" by clicking a button
    By sanjeev devaliya in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 05-25-2013, 12:11 PM
  5. "Clicking" effect to a shape via macro
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-08-2013, 06:34 PM
  6. Clicking "yes" in the excel pop up box leads to macro running???
    By dmc123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2010, 01:55 PM
  7. VBA gives "400" error when clicking on a button to run a macro
    By Kaigi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2009, 02:52 PM

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.6.0 RC 1