+ Reply to Thread
Results 1 to 5 of 5

Create an error message when retrieving information for invalid dates

  1. #1
    Forum Contributor
    Join Date
    12-16-2011
    Location
    Portland, OR
    MS-Off Ver
    Excel 2016 Preview
    Posts
    105

    Create an error message when retrieving information for invalid dates

    In retrieving stock info from the internet there is a problem if a user selects a date that was prior to the existence of the stock. Currently, if that happens, the user just gets blank cells.

    The attached image shows 2 printscreens.

    The top image shows a table that isn't a problem.
    The bottom image shows an attempt to retrieve info 2 years prior to the existence of data and Yahoo says data is unavailable.

    What code can I insert that will alert a user that they need to pick a different date? The alert can be something as simple as inserting XXXX instead of a stock price. Definitely not looking for a fancy solution.

    Thanks all!!


    StkErr.jpg

    Here is my code:


    Please Login or Register  to view this content.
    Last edited by Habanero Time; 03-12-2012 at 11:56 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Create an error message when retrieving information for invalid dates

    can you retrieve data of listing of each of the stocks. in that case you can put a condition that beginning date should be >=that listing date.
    I am not an expert. better solutions may be available
    [email protected]

  3. #3
    Forum Contributor
    Join Date
    12-16-2011
    Location
    Portland, OR
    MS-Off Ver
    Excel 2016 Preview
    Posts
    105

    Re: Create an error message when retrieving information for invalid dates

    Quote Originally Posted by venkat1926 View Post
    can you retrieve data of listing of each of the stocks. in that case you can put a condition that beginning date should be >=that listing date.
    Venkat, I'm not sure what you're asking. Can you ask it a different way?

  4. #4
    Forum Contributor
    Join Date
    12-16-2011
    Location
    Portland, OR
    MS-Off Ver
    Excel 2016 Preview
    Posts
    105

    Re: Create an error message when retrieving information for invalid dates

    This code is looking for Table 15 on the web page.

    There must be a way to have the code check for Table 15. If there's no Table 15 then put XXXX in the appropriate cell and continue the loop.

  5. #5
    Forum Contributor
    Join Date
    12-16-2011
    Location
    Portland, OR
    MS-Off Ver
    Excel 2016 Preview
    Posts
    105

    Re: Create an error message when retrieving information for invalid dates

    Figured it out!
    Adding this piece to check if any data was retrieve. If no data was retrieved, input "INVALID DATE"


    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