Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code which retrieves the current market quote of
a company based on the ticker symbol from Google finance. I am looking for a more efficient way to recalc the function/update it. Currently I have a button with a macro that just calculates the whole worksheet. Which has 40+ ticker symbols so it takes 30-45 sec's to calc. Is there a more efficient way to do this. Below is the code I use to retrieve the stock price. Public Function googleQuote(symbol As String) As Variant 'Source is google.com/finance Dim xmlhttp As Object Dim strURL As String Dim CompanyID As String Dim x As String Dim sSearch As String strURL = "http://www.google.com/finance?q=" & symbol Set xmlhttp = CreateObject("msxml2.xmlhttp") With xmlhttp ..Open "get", strURL, False ..send x = .responsetext End With Set xmlhttp = Nothing 'Find "setCompanyID(" that google assigns to each ticker symbol sSearch = "setCompanyId(" CompanyID = Mid(x, InStr(1, x, sSearch) + Len(sSearch)) CompanyID = Trim(Mid(CompanyID, 1, InStr(1, CompanyID, ")") - 1)) 'Use the company ID to retrieve data needed sSearch = "ref_" & CompanyID & "_l""" googleQuote = Mid(x, InStr(1, x, sSearch) + Len(sSearch)) googleQuote = Left(googleQuote, InStr(1, googleQuote, "<") - 1) End Function Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
SUMIF function not calculating from closed worksheet | Excel Worksheet Functions | |||
Worksheet is not calculating | Excel Worksheet Functions | |||
worksheet calculating SLOW | Excel Discussion (Misc queries) | |||
calculating the name of a worksheet | New Users to Excel | |||
Calculating using data from another worksheet | Excel Worksheet Functions |