How do I download a stock price in Excel 2013? Is there an equivalent to Google Doc's GoogleFinance spreadsheet function?
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.
Solution 1:
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.
Solution 2:
There are four Stock apps in the Office Store at the moment. Two of them are free :
Stock Connector
Stock Tile