I forget exactly who's scripts I modified for this one (and I'll admit, I'm an absolute VBA novice, I don't claim to be good by at all so if it's sloppy, don't be too harsh!), I actually collected a variety of sources to make this work. But this macro simply grabs the two ticker symbols in A2 and A3 and puts the last prices (from yahoo finance) below. I know it's a really simple tool, but I haven't found anything like this floating around, it will be useful to me....I hope this will help someone else also.
last stock price from yahoo finance
-
-
-
Re: last stock price from yahoo finance
hmmm, I think you've got a bit of code missing. Where's the code that actually downloads the stock data? your workbook just seems to pull data from a spreadsheet called Quotes
Scratch the above, just re-read the code -
Re: last stock price from yahoo finance
FWIW I use
Code
Display MorePublic Function GetTicker(ticker As String) As Double ticker = LCase(ticker) With CreateObject("MSXML2.XMLHTTP") .Open "GET", "http://query.yahooapis.com/v1/public/yql?q=Select content from html where url%3D'http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3D" & ticker & "' and xpath%3D'%2F%2Fspan[%40id%3D"yfs_l84_" & ticker & ""]'", False .send GetTicker = Val(Split(.responsetext, "<span>")(1)) End With End Function
I then use this as a worksheet function:
-
Re: last stock price from yahoo finance
Nice submissions, both.
blah17 - Nothing wrong with it at all. Only a minor quibble in that it'll fall over in versions of Excel prior to 2007 because of the reference to column ZA. Also, you don't need to select a range before doing something with it
Attached has been re-written slightly to address the points above, plus it will pull back a list of up to 30 symbols...
Kyle123 - Nice to have an example of downloading using REST API.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!