+ Reply to Thread
Results 1 to 11 of 11

Pulling real time data from excel on a daily basis (stock data)

  1. #1
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Pulling real time data from excel on a daily basis (stock data)

    Hello,

    I'm using Excel to pull in real time data for the stock market. It's working great and I have data in categories that gives me gains/losses broken down for each area I want. What I would like to do is pull that data daily into another worksheet so I can create a line chart. Basically, get the result of each day to create a visual chart. I don't need a chart of the "current data" but what I would like to do is pull the current data on a daily basis (at the end of the market) keeping the data concrete and then create a visual chart from that over time. I was told there is a way to do that with VBA Macros.

    Would someone be able to help me with the VBA code? I have attached a sample spreadsheet. If I have the right code, I should be able to setup a windows scheduler from there.

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Pulling real time data from excel on a daily basis (stock data)

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Pulling real time data from excel on a daily basis (stock data)

    Works perfectly! Thank you!

    Does this run at a specific time of day? I ran it manually and it worked fine and that is ok if that is the case and I can work on it.

  4. #4
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Pulling real time data from excel on a daily basis (stock data)

    Nevermind, I see that is what the Windows task scheduler will do. This stuff is all new to me. Thanks again!

  5. #5
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Pulling real time data from excel on a daily basis (stock data)

    I have just one question. If I decided that I wanted to include other totals in this how would I add those to this VBA code? Could I just insert the extra cell and column information in the section or should I create another module for that?

    For example, can I just add another subtotal column and subtotal cell? It would be the same date.
    Const sDAILY_DATA_SHEET As String = "Sample Spreadsheet"
    Const sGRAPH_DATA_SHEET As String = "Gain-Loss Data"
    Const sCOLUMN_SUBTOTAL As String = "B"
    Const sSUBTOTAL_CELL As String = "I8"
    Const sCOLUMN_DATE As String = "A"

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Pulling real time data from excel on a daily basis (stock data)

    Hi again,

    Thanks for your feedback.

    I'd need a bit more information in order to answer your latest questions - e.g. Where are the extra subtotals located? Are they all on the same row? Will they always be in those locations? Where do you want them copied to? To the same "last row" on the Graph Data worksheet? To the next free row? etc. etc.

    What you need can almost certainly be accommodated, but it'll be much easier if we keep the mind-reading to a minimum

    Irish15? Do you have a connection?

    Regards,

    Greg M

  7. #7
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Pulling real time data from excel on a daily basis (stock data)

    Thanks for the reply. I have a dashboard setup where I can pull all the info easily (all on the same spreadsheet so the daily data sheet row could stay the same). Basically, I have 3 other totals I would like to grab and pull over to the same "gain-loss data" spreadsheet. So, that would be 3 extra columns to the code you wrote. The date would be the same.

    I tried playing around with it but just kept messing it up. The best I got was to add 4 separate modules with the same code you provided but each total goes to a new line and the same date is repeated. I could just keep them all on the same row but not sure if that is possible. I can certainly work with that but not sure if it is easy to just add these to one module somehow.

    Hope I explained that correctly. Thanks again for your help with this!

  8. #8
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Pulling real time data from excel on a daily basis (stock data)

    If helpful, here is pic of what I have.
    Last edited by Irish15; 05-07-2020 at 08:39 AM.

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Pulling real time data from excel on a daily basis (stock data)

    Hi again,

    This is a different approach, so see if the following code does what you need (I've just put in "guess values" for the locations of the various subtotal cells):

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M

  10. #10
    Registered User
    Join Date
    04-01-2020
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Pulling real time data from excel on a daily basis (stock data)

    Works perfectly! Thanks so much. Would have never figured it out on my own. I should have mentioned the extra cells the beginning so thank you for the extra work.

    Also, just noticed you are from Dublin. Awesome! I have family from Limerick.

    Cheers mate

  11. #11
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Pulling real time data from excel on a daily basis (stock data)

    Hi again,

    Many thanks for your feedback.

    You're welcome - glad I was able to help.

    Ok on Limerick - in terms of US distances Limerick is only "around the corner" from Dublin!

    Regards,

    Greg M

+ 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: 16
    Last Post: 05-06-2020, 10:34 AM
  2. Replies: 1
    Last Post: 05-01-2018, 05:15 PM
  3. Getting stock info from a site automatically on a daily basis
    By dalewms3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2015, 05:41 AM
  4. Record real time data (stock quote)
    By chaitreya in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2015, 11:31 PM
  5. Replies: 1
    Last Post: 03-21-2013, 10:45 PM
  6. Replies: 0
    Last Post: 09-23-2012, 12:34 PM
  7. Replies: 1
    Last Post: 01-07-2005, 08:06 PM

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