+ Reply to Thread
Results 1 to 6 of 6

Macro quitting before completion

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Macro quitting before completion

    I am running a macro that grabs info from Yahoo. The macro is working fine except when it encounters two particular situations.

    The macro is designed to grab a closing stock price for a date specified for a list of Symbols in column A and the date in column B. The closing price is then displayed in column D.

    The problems (there are two that I found) I am running into is that when the Macro encounters a symbol in Column A and is not recognized, an error message pops up and the macro stops altogether. I want the macro to continue to run down the list but I can't figure out where in the macro it is stopping and, more importantly, how to make it continue. Any help is appreciated. I have attached a copy of file if needed (if opened, you can see it stops working after row 11). Thanks

    The other issue, which is related to the first issue somewhat is if the macro runs into an invalid date in column B (e.g. the user may enter a date that is for a Saturday or Sunday in which Yahoo would not have any data). This also causes the macro to stop.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by maacmaac; 11-25-2008 at 04:30 PM.

  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
    Put Resume at the end of your error handler.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176
    I put resume (plus some additional code) in the error handler and that cleared up the first issue if symbol is not found in column A. Still having trouble if the user enters and invalid date in column B (e.g. enters a Saturday, Sunday, holiday, etc). Not sure if I need another resume someplace in the code and I am just not seeing it.

    Please Login or Register  to view this content.

  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
    Set breakpoints; what if the error is none of those you catch?

  5. #5
    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.

  6. #6
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176
    That did the trick. Code is working as expected. As always, thank you and all others that take the time out of their day to help others with Excel issues.

    P.S. I really liked your advice for setting breakpoints. This was something I did not know even existed before you made your comment. This is really helpful for debugging.

    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