Excel on mac, vba code to retrieve stock quotes from yahoo finance

jferri

Board Regular
Joined
Jun 24, 2003
Messages
58
Hi everyone. Working on a mac in Excel 2016, and looking for a way to create a user defined function to pull in data from Yahoo Finance API. Searched all over the web, and it is quite easy to do this on a PC, but there is sparse information on how to accomplish this on a mac. Any help would be greatly appreciated. It is basically the call to the external data source that I cant seem to figure out.

The following works fine on my non-mac machine. I'm looking for the equivalent that will work on my mac.

Function StockQuote(strTicker As String)

Dim strURL As String, strCSV As String
Dim dbClose As Double

' Compile the request URL
strURL = "http://download.finance.yahoo.com/d/quotes.csv?s=" & strTicker & "&f=l1"

Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", strURL, False
http.Send
strCSV = http.responseText

dbClose = Val(strCSV)
StockQuote = dbClose

Set http = Nothing

End Function
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top