+ Reply to Thread
Results 1 to 14 of 14

Why wont this macro stop?

  1. #1
    Registered User
    Join Date
    03-07-2008
    Posts
    25

    Why wont this macro stop?

    Hello,

    Im pulling my hair out over here. All this macro is supposed to do is execute a data download every ten seconds until there is a value in C11 and then send an email and close.

    What seems to be happening is that it downloads, emails, closes... but then in ten seconds the sheet reappears and does it all again. Help pleaseee!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Take a look at the example in Help for the OnTime method to see how to cancel a pending OnTime setting.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-07-2008
    Posts
    25
    I did a bit of further research and am now trying a different method

    Please Login or Register  to view this content.

    Why does the timer never kick in? The cell just blazes 1 thru 3 and never ends. Im just testing it, and I know it'll endlessly loop but Im expecting a pause and Im just not getting it no matter what I do.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please Login or Register  to view this content.
    In the first statement, you're rescheduling loop1 to run about a million times a second, and there's nothing in the loop that effects C11, so it runs forever.

  5. #5
    Registered User
    Join Date
    03-07-2008
    Posts
    25
    Thanks for the help Shg.

    I decided to simplify this as much as I could. This is what Ive got, and it works just great.. Except for one thing..

    Please Login or Register  to view this content.
    The problem is that when this sheet opens. (Ive got it to AutoOpen open1() at 4pm daily thru task scheduler), I have other sheets open at the time. So, if I change focus to a different sheet the macro will attempt to run on that sheet. I tried using
    Please Login or Register  to view this content.

    in test2(), but then the window switches to SWEEP.XLS out of what Im working in. Can I activate it without switching the focus?

    Any help is greatly appreciated
    Last edited by liquidskin; 11-14-2008 at 11:27 AM.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Sounds like your two other macros need to make sure they're operating on ThisWorkbook and not ActiveWorkbook.

  7. #7
    Registered User
    Join Date
    03-07-2008
    Posts
    25
    Quote Originally Posted by shg View Post
    Sounds like your two other macros need to make sure they're operating on ThisWorkbook and not ActiveWorkbook.

    Please Login or Register  to view this content.
    Still doing the same thing. Say I have XYZ.xls open and this sheet opens, if I go over to XYZ.xls it executes the first statement in test2()

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please Login or Register  to view this content.
    Look in THESE macros.

  9. #9
    Registered User
    Join Date
    03-07-2008
    Posts
    25
    Quote Originally Posted by shg View Post
    Please Login or Register  to view this content.
    Look in THESE macros.
    I realized I botched that up after I did it. Clear and SecurityDistribution are now being called from thisWorkbook, but its STILL doing it.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Liquidskin, it doesn't matter WHERE they are being called from. Look in the code and ensure they operating on the workbook you want them to.

    By default, any range reference is to the ACTIVE workbook. You need to change those references to refer to a PARTICULAR workbook, maybe THISWorkbook.
    Last edited by shg; 11-14-2008 at 12:14 PM.

  11. #11
    Registered User
    Join Date
    03-07-2008
    Posts
    25
    Quote Originally Posted by shg View Post
    Liquidskin, it doesn't matter WHERE they are being called from. Look in the code and ensure they operating on the workbook you want them to.

    By default, any range reference is to the ACTIVE workbook. You need to change those references to refer to a PARTICULAR workbook, maybe THISWorkbook.
    Shg,

    Clear and Sec.Dist are in thisWorkbook.

    This is what clear looks like.

    Please Login or Register  to view this content.
    so if Im running
    Please Login or Register  to view this content.
    Why would it be doing that? I must be missing something...

    Appreciate it

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    In Sub Clear, this:
    Please Login or Register  to view this content.
    refers to A10 on the ACTIVE sheet, in whatever workbook that is.

    If you want it to refer to a sheet in the workbook that the code is in, you have to change it to,
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-07-2008
    Posts
    25
    Quote Originally Posted by shg View Post
    In Sub Clear, this:
    Please Login or Register  to view this content.
    refers to A10 on the ACTIVE sheet, in whatever workbook that is.

    If you want it to refer to a sheet in the workbook that the code is in, you have to change it to,
    Please Login or Register  to view this content.


    That results in a 1004 Runtime Error when I'm active in another workbook.

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    There's no need to select:
    Please Login or Register  to view this content.

+ 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