+ Reply to Thread
Results 1 to 4 of 4

Help needed (creating VBA macro to retrieve stock info)

  1. #1
    Registered User
    Join Date
    03-19-2012
    Location
    waterloo, ontario
    MS-Off Ver
    Excel 2010
    Posts
    3

    Help needed (creating VBA macro to retrieve stock info)

    Hey,
    I am fairly new to excel programming and just looking for some help on a personal project. (Please view file first to get and overview of what I'm looking to do)
    I would like to create a VBA macro that would be able to retrieve stock info based on my worksheet. Moreover I would like to like the the vba macro to allow for database expansion (i.e. allow user to input new data on a daily basis (get alert info)

    Any help is appreciated
    Btw, would it be a good idea to later connect this file to Microsoft Access 2010?
    Thanks,
    Last edited by L80n; 03-19-2012 at 02:53 AM.

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

    Re: Help needed (creating VBA macro to retrieve stock info)

    you have not given complete information. what do you want? your sheets are not RAW sheets. you have already stated some pivot able in the second sheet and some filtering in the third sheet. Yo;u have also split the screen in the third sheet it would be easier to help you if the data is raw sheets and you explain what you want
    all cosmetic changes may be made JUST BEFORE PRESENTATION TO YOUR BOSS OR USER.; (and not before the macros are written).



    I presume you want the "open" price for the next day is to be filled in column H in sheet "E-mail data". you must be having some reason for naming this file like this
    if you want open price of theose stocks then from where you would like to get. do you have already get some arrangement to get historical data. Perhaps you can get the IRET data for 7 Dec 2011 (G2 plus one day) from yahoo finance.
    http://finance.yahoo.com/q/hp?s=IRET...=07&f=2011&g=d

    in this webpage you see the name of the smbol IRET,the date 2011 7th day 11 means december because the month number starts form 0 for January
    and g at the end is daily data;.

    how you do it (if you have yahoo user id and password for any of their items like mail etc log in first )

    open an excel sheet (2007)
    click data
    click import from web data (second icon from the left)
    replace the existing web address to the above address and click go
    when the data is downloaded click only the table you want by clicking yellow horizontal arrow and click IMPOT at the bottom and choose the cell where it is to be donwloaded
    normallly A1 and click ok.
    the data for 7th jan 11 will be downloaded and you can choose open price
    a macro can be written changing the changeable in the web page like symbol and dates.

    you can also download data into excel (open another sheet and download this data using "new web query")
    do you want to download from yahoo finance or from some other data source

    suggest post raw data sheets and explain.
    I am not an expert. better solutions may be available
    $$$$venkat1926$$$$@gmail.com

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

    Re: Help needed (creating VBA macro to retrieve stock info)

    tentatively I have written a macro for you. I am sending the file 'L80N.xlsm"
    see the column H in sheet ("E mail data"
    the open prices are filled by the macro
    if you want to retest you can run the macro "test"

    there is only one big problem. You have 334 stocks and mostly for each stock the date (co. G) is different ( may be one to three stocks may have same date). the macro downloads the rices for the next day to corresponding col. G dates and copy it to col H of the email data sheet. Temporarily the data is downloaded in sheet 3.

    IT TAKES NEARLY 9 MINUTES TO FILL THE DATA BY THE MACRO
    once you experiment with this with patience. meanwhile let me check whether some speedier solution can be made.
    see the macro in the vb editor to understand the logic of the macro
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-19-2012
    Location
    waterloo, ontario
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Help needed (creating VBA macro to retrieve stock info)

    Hey venkat1926 I really appreciate you doing this for me this addressed exactly what I was looking for. Based on the macro that you provided me if I were to try and modify the code, would it be possible to retrieve information such as: Current price, Sector, Industry and Market Cap based on that macro. Sorry for asking all these questions fairly new to excel macro. For this project i'm basically try to run some analysis on stocks that my system recommends (i.e the email data i receive). Therefore on a nightly basis I receive the emails and then input the stock info into the excel spreadsheet. My goal is to utilize excel to see if the recommendations are working out the way they are suppose to, that's why i need to retrieve stock data from the net. Hopefully this info is more helpful, do you have skype by chance, i would be able to better communicate my goal via skype. Thanks for all your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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