+ Reply to Thread
Results 1 to 3 of 3

Macro stops running randomly with no break or error when looping

  1. #1
    Registered User
    Join Date
    02-16-2012
    Location
    sa
    MS-Off Ver
    Excel 2007
    Posts
    80

    Macro stops running randomly with no break or error when looping

    Good day,

    I am currently do the following:

    1. Declare public variables
    2. Run a sub Plot() which loops (11 times) and calls calls subs from other modules in order to plot graphs
    eg Module1 and module2 which uses the public variables and plots graphs then calls Module 3 (also uses the public variable) then puts the graphs by copy pasting into a powerpoint presentation, saves and then closes it. I need to create 11 powerpoint presentations

    I am getting many problems.

    1. The code just stops with no error or break eg halfway through creating a powerpoint
    2. If I run sub Plot() more than once consecutively it does not create all powerpoints. it justs opens the powerpoint (does not paste anything) then moves onto the next powerpoint without closing and saving the first etc...it does this 11 times.
    3. If i close excel and open it sometimes runs correctly for loops 1 to 10. but stops halway whilst creating the last powerpoint.


    I am not sure if its a memory problem, or a public variable issue. but its driving me insane!
    Please help!

  2. #2
    Registered User
    Join Date
    02-16-2012
    Location
    sa
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Macro stops running randomly with no break or error when looping

    I hope this makes sense. Do I need to clarify anything?

    Please help. This has been bugging me for over a month now and I cant seem to get past it!

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Macro stops running randomly with no break or error when looping

    Hi blh,

    This might be a timing problem where you macro is sending things to the wrong program or part of the sequence. Look at using "DoEvents" in your VBA code. I put these before and after things that may take a long time to process to insure my VBA gives enough time for other things to happen before starting again.

    https://msdn.microsoft.com/en-us/lib.../gg264522.aspx
    https://support.microsoft.com/en-us/kb/118468
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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 Stops Running
    By bhbjk1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2015, 08:22 PM
  2. [SOLVED] 'True' message box and macro stops running
    By Aaron092 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2014, 09:43 AM
  3. Protection Stops Macro From Running
    By Keith Burgess in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-11-2008, 07:15 AM
  4. macro randomly stops working
    By johnlengacher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2006, 02:50 PM
  5. [SOLVED] Macro stops running after file has moved
    By LWhite in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-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