Thread: Stock Quotes
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Stock Quotes

I get same results in cells and in VBA with lots of decimals, see debug
results below

Sub MSNSQtest()
' with ref to
' MSNStockQuote, MSN Stock Quote Add-in for XL
Dim bid As Double, ask As Double
Dim sqf As MSNStockQuote.Functions
Const Q As String = """"

ActiveWorkbook.Worksheets.Add

Range("A1") = "MSFT"
Range("B1") = Replace("=MSNStockQuote('MSFT','Bid Price','US')", "'", Q)
Range("C1") = Replace("=MSNStockQuote('MSFT','Ask Price','US')", "'", Q)

Debug.Print Range("B1").Value2, Range("C1").Value2
' 30.0699996948242 30.0900001525879

Set sqf = New MSNStockQuote.Functions
bid = sqf.MSNStockQuote("msft", "Bid", "us")
ask = sqf.MSNStockQuote("msft", "Ask", "us")

Debug.Print bid, ask
' 30.0699996948242 30.0900001525879

End Sub

Curiously, 2 minutes after running the above I got the following prices from
MS's moneycentral site
Bid: 30.29 Ask: 30.30

Seems odd the prices would have changed that much in that time; I ran the
above routine again and got same results. Quite a discrepancy!

Regards,
Peter T

PS - all results above obtained moments before posting here


"Ken G" wrote in message
...
If I use the Excel addin to retrieve a stock quote it gives 3 decimal
places,
however if I use VBA code to retrieve the quote from MoneyCentral it only
gives two decimal places. This seems to be a limitation of MoneyCentral
rather than the vba code. Where does the addin get its data from?

What code can I use in vba to retrieve 3 decimal places?