+ Reply to Thread
Results 1 to 12 of 12

Macro interference

  1. #1
    Forum Contributor
    Join Date
    09-12-2021
    Location
    Mexico
    MS-Off Ver
    Office 2019
    Posts
    169

    Macro interference

    Is it a good idea to insert "ApplicatiionEnableEvents = false" VBA code to prevent macros from stopping or otherwise malfunctioning when others are running? I seem to be having problems of this type and would appreciate any advice or suggestion on how to deal with it. Many thanks in advance.
    Last edited by AliGW; 09-27-2021 at 05:46 PM.

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Macro interference

    If you have macros that trigger when cell contents change and then you have other macros that change the contents of those cell then you can get into some difficulty. I sometimes disable events when I'm updating cell contents or doing anything else that might trigger another macro.

    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,082

    Re: Macro interference

    Specifically, if you have a Worksheet Change Event handler and that event handler makes changes on the sheet, you should bracket the change(s) with ApplicatiionEnableEvents = False and ApplicatiionEnableEvents = True.

    Similarly, if you have a Selection Change Event handler, and you select cell(s) within it, same rules.

    In the worst case, it can cause a loop. Best case, it will fire more often than it needs to.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    09-12-2021
    Location
    Mexico
    MS-Off Ver
    Office 2019
    Posts
    169

    Re: Macro interference

    Thanks. My problem seems to be related to different macros running on different schedules. If a macro begins while another is running, should that be a problem? Do these macros execute simultaneously, or do they do so in some kind of queue? Thanks again for your help.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,082

    Re: Macro interference

    Not a clue. Hypothetical questions with no example code or sample workbooks are difficult, if not impossible, to answer. Probably a poor analogy, but it's a bit like asking "what would happen if I drive very fast on a winding road when it's raining hard and I turn the steering wheel sharply?"

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Macro interference

    If your macros are running on timers then perhaps you should have a global variable that prevents two macros running at the same time. Like:

    Please Login or Register  to view this content.
    Then, at the start of each macro:
    Please Login or Register  to view this content.
    Then at the end of the macro:
    Please Login or Register  to view this content.
    WBD

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,525

    Re: Macro interference

    Quote Originally Posted by Programmernovice View Post
    If a macro begins while another is running, should that be a problem? Do these macros execute simultaneously, or do they do so in some kind of queue?
    If you run the second macro during the execution of the first macro, the execution of the first one is suspended until the end of the second one. VBA does not support multithreading.
    It is true that there are some possibilities of achieving multithreading, but this is already a higher driving school.

    Artik

  8. #8
    Forum Contributor
    Join Date
    09-12-2021
    Location
    Mexico
    MS-Off Ver
    Office 2019
    Posts
    169

    Re: Macro interference

    Many thanks WBD. Some of my macros are, indeed, running on timers. I have added the code you suggested, hopefully that will correct the problem.

    I reatly appreciate your helping me out.

  9. #9
    Forum Contributor
    Join Date
    09-12-2021
    Location
    Mexico
    MS-Off Ver
    Office 2019
    Posts
    169

    Re: Macro interference

    Thanks for replying, Artik. I have tried the solution proposed by WBD, hopefully that will work.

    Your help is greatly appreciated

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,369

    Re: Macro interference

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,082

    Re: Macro interference

    Thanks for the rep.

  12. #12
    Forum Contributor
    Join Date
    09-12-2021
    Location
    Mexico
    MS-Off Ver
    Office 2019
    Posts
    169

    Re: Macro interference

    Thanks for the suggestion TMS I will try it out now. I appreciate your input.

+ 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. Macro that AUTOMATICALLY activates another macro without human interference?
    By Mangorni in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-06-2017, 01:18 PM
  2. [SOLVED] Macro that AUTOMATICALLY activates another macro without human interference? HELP
    By Mangorni in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-24-2016, 09:23 AM
  3. Personal Macro Workbook interference with other workbook macro(s)
    By Xanlithe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2015, 09:41 AM
  4. Replies: 1
    Last Post: 10-10-2015, 01:00 AM
  5. Interference between Macros?
    By RDS in forum Excel General
    Replies: 1
    Last Post: 02-20-2012, 06:00 AM
  6. Interference between 2 ComboBox
    By Magic_Doctor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2011, 03:38 PM
  7. [SOLVED] dragging without interference
    By BorisS in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-20-2005, 04:06 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