+ Reply to Thread
Results 1 to 3 of 3

Could someone please teach me how to write VBA code to download historical data from web

Hybrid View

  1. #1
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    803

    Could someone please teach me how to write VBA code to download historical data from web

    Data Source (Yahoo Finance): https://finance.yahoo.com/quote/GOOGL/history?p=GOOGL

    You may download one year range of data (default on the webpage), or last 30 days of data. It does not matter too much.

    I would like to know how to write VBA to pull data from web first, then I will modify the code to pull data for a list of symbols (List of S&P 500 companies).

    Thanks.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,929

    Re: Could someone please teach me how to write VBA code to download historical data from w

    You don't have to write VBA. If you have Office 365, this is now a built-in feature. Please look up the STOCKHISTORY function.

    Quick example:

    Values as displayed
    A
    B
    C
    1
    GOOGL
    Date
    Close
    2
    1/2/2020
    $ 1,368.68
    3
    1/3/2020
    $ 1,361.52
    4
    1/6/2020
    $ 1,397.81
    5
    1/7/2020
    $ 1,395.11
    6
    1/8/2020
    $ 1,405.04
    7
    1/9/2020
    $ 1,419.79
    8
    1/10/2020
    $ 1,428.96
    9
    1/13/2020
    $ 1,440.03
    10
    1/14/2020
    $ 1,430.59
    11
    1/15/2020
    $ 1,439.20
    Underlying formulas
    A
    B
    C
    1
    GOOGL
    =STOCKHISTORY(A1,"1/1/2020",TODAY())
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    803

    Re: Could someone please teach me how to write VBA code to download historical data from w

    Quote Originally Posted by 6StringJazzer View Post
    You don't have to write VBA. If you have Office 365, this is now a built-in feature. Please look up the STOCKHISTORY function.
    Good to know, but I think I do need VBA code. I don't think I want to do it one sheet at a time. As first post states, I would like to pull historical data for a list of S&P 500 companies, not just a few companies.

    Edit: I think I can write VBA code from excel function =STOCKHISTORY("MSFT",TODAY()-30,TODAY())
    Last edited by VAer; 08-31-2021 at 10:34 PM.

+ 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. Replies: 6
    Last Post: 02-11-2021, 09:12 PM
  2. VBA code to move data from a entry sheet to a historical sheet by date
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-17-2014, 07:15 PM
  3. [SOLVED] Code to move data from an entry table to a historical table by date.
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2014, 11:04 AM
  4. Replies: 6
    Last Post: 11-18-2013, 11:28 PM
  5. How to write a macro to download a webpage table in MS Excel every hour
    By rjbirosel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2013, 07:20 AM
  6. How to write download automatically at fixed times
    By teeger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2011, 10:46 AM

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