7

In a Google Docs spreadsheet, I can use this cell formula:

=GoogleFinance("GOOG", "price")

to download the latest price of a stock. Is there an equivalent function in Excel 2013?

Earlier versions of Excel had a smart tag feature that downloaded a ton of data for each ticker (too much, in fact, if you just need the price), and I've seen sources that suggest the Bing Finance app for Excel 2013. Unfortunately this has been discontinued.

Is there a simple way to do this? I literally just need the most recent price, and I don't care if it's delayed, comes from Yahoo Finance, etc. Presumably I could write VBA code to download a CSV file from YF, parse it and so on, but I'm hoping to avoid creating a macro-enabled workbook.

8
  • This is not a feature that Excel supports out of the box
    – Ramhound
    Apr 23, 2014 at 16:21
  • 1
    In excel 2007/2010 data - existing connection - MSN MoneyCentral Investory Stock Quotes works, was this removed for 2013? edit - yeah it looks like it was removed and Bing Finance App is the "replacement". You could set up a data - from web query to msn money, but that would be tedious. Apr 23, 2014 at 16:34
  • @Raystafarian How would I set up a new data query?
    – Michael A
    Apr 23, 2014 at 16:45
  • It seems you may need to use power query in 2013 source Apr 23, 2014 at 16:50
  • 1
    @harrymc I'm not the OP, but I think the most valuable answer would be something that uses existing functionality in Excel 2013 and/or is free.
    – Excellll
    Mar 1, 2016 at 14:52

3 Answers 3

5

You can use a UDF like this -

Option Explicit

Public Function GetTickerPrice(ByVal ticker As String) As Double

    Dim IE As Object
    Dim pageData As Object

    Set IE = CreateObject("InternetExplorer.Application")
    Dim URL As String
    URL = "http://www.msn.com/en-us/money/stockdetails/fi-126.1." & ticker & ".NAS?symbol=" & ticker & "=PRFIMQ"

    IE.Navigate URL

     Do Until IE.ReadyState >= 4
            DoEvents
     Loop

     Application.Wait Now + TimeSerial(0, 0, 5)

     Set pageData = IE.document

     GetTickerPrice = pageData.getElementsByClassName("precurrentvalue")(0).innertext

     Set IE = Nothing
     Set pageData = Nothing
End Function

Now you can use GetTickerPrice("GOOG") and get the current price.


I did take this over to Codereview.SE for some input.

8
  • 2
    Would it not be best to format as Double instead of Long, so you don't lose the decimal information? Then the end user can decide if they want to round it.
    – Jonno
    Feb 27, 2016 at 17:17
  • Thanks, this works! But it's really slow -- about 20 seconds to get one stock price. I'm assuming opening IE and loading the URL there are the bottlenecks. Is there anyway to get around this?
    – Excellll
    Feb 29, 2016 at 16:29
  • @Jonno yes, I see Excellll made the change Mar 2, 2016 at 9:46
  • @Excellll I'll try to see if there's a way around it, maybe forcing IE to be silent, but unless we can find a database like there used to be, we might be stuck (at least for older versions of excel). Mar 2, 2016 at 9:47
  • 1
    @Excellll there's a pretty decent response at CodeReview to my approach. It seems like it's different enough that it wouldn't be considered the same as my answer. Mar 2, 2016 at 16:04
3
+100

There are four Stock apps in the Office Store at the moment. Two of them are free :

Stock Connector

Stock Connector

Stock Tile

enter image description here

-1

There is an Add-In called Stock Quote Add-In For Excel 2013 which does this, and has a version for 2013. Personally I could not get it to work, but it has been around for a few years so it was probably just me.

1
  • 2
    Welcome to Super User. This does help answer the question but could you possibly add info about how this plugin should be used?
    – LJD200
    Feb 29, 2016 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .