+ Reply to Thread
Results 1 to 5 of 5

One macro prevents another from working

  1. #1
    Registered User
    Join Date
    04-21-2009
    Location
    Nottingham
    MS-Off Ver
    Excel 2003
    Posts
    66

    One macro prevents another from working

    Hi all,
    I have a macro built in to one of my worksheets (under view code).

    This prompts a user to select either “Ok” or “Cancel” from a message box.

    Please Login or Register  to view this content.
    I also have a macro that is designed to run upon save or closure of the workbook which is built in to “this workbook”.

    Please Login or Register  to view this content.
    No for some reason, if “cancel” is selected from the first macro – it prevents the second macro from running on closure. If “ok” (or the first macro is not run) the second one will run perfectly.

    Can anyone help please??

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: One macro prevents another from working

    You have to turn ENABLEEVENTS back on at the bottom of the Worksheet_Change macro:
    Please Login or Register  to view this content.
    This piece of code MEANS "turn off other macros for now"...so you have to turn them back on when you're done with your code.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: One macro prevents another from working

    In fact, I would reorder your macro events to this order, it appears you could accidentally abort your code with the MSGBOX and still leave the events turned off:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-21-2009
    Location
    Nottingham
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: One macro prevents another from working

    Absolute star - thank you very much

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: One macro prevents another from working

    My pleasure! If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED].



    (Also, use the "scales" icon across from the post dates to leave Feedback, it is appreciated)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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