LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Calculating a worksheet

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUMIF function not calculating from closed worksheet Bill Excel Worksheet Functions 1 March 3rd 10 09:17 PM
Worksheet is not calculating David Excel Worksheet Functions 0 April 22nd 09 08:40 PM
worksheet calculating SLOW Jase Excel Discussion (Misc queries) 2 May 14th 08 01:20 AM
calculating the name of a worksheet outlook help New Users to Excel 4 January 27th 05 10:38 PM
Calculating using data from another worksheet Sid N Excel Worksheet Functions 1 October 28th 04 09:58 PM


All times are GMT +1. The time now is 06:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"