Thread: Stock Quotes
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Ken G Ken G is offline
external usenet poster
 
Posts: 34
Default Stock Quotes

The Money Central web page seems to be locked at 2 decimal places.
I'm not all that sharp on VBA so I have to try to work out how to build in
the "Dim Double" to get my data as double precision. Can you help? The code
I'm using is modified from an old one I found somewhere on the web ....
ozgrid.com I think.
__________________________

Sub Update()

' Macro recorded 9/30/2004 by Atmel PC - modified 12/23/09 by Ken G

Range("A1").Select

' Check for protected sheet

'ActiveSheet.Unprotect Password:="****"

'Get current date
Range("L3").Select
Selection.Copy
Range("H3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Application.ScreenUpdating = False

' Local Variables
Dim rngLookUpSym As Range, rngQuerySym As Range,
rngQuerySymCo As Range
Dim rngQuerySymData As Range
Dim qryTableStocks As QueryTable


' Step 1 : Set Data Ranges
Set rngLookUpSym = Worksheets("Holdings").Range("A5")
Set rngQuerySym = Worksheets("Web Query Page").Range("A1")
Set rngQuerySymCo = Worksheets("Web Query Page").Range("A5")
Set rngQuerySymData = Worksheets("Web Query Page").Range("A5").Range("D1")
Set qryTableStocks = ThisWorkbook.Worksheets("Web Query
Page").QueryTables(1)

' Step 2 : Loop through list of stocks and retrieve market data
Do While rngLookUpSym < ""
rngQuerySym = rngLookUpSym
With qryTableStocks
.Connection = _

"URL;http://moneycentral.msn.com/investor/external/excel/quotes.asp?SYMBOL="
& "AU:" & rngQuerySym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
rngLookUpSym.Range("B1") = rngQuerySymCo
rngLookUpSym.Range("G1") = rngQuerySymData.Value
Set rngLookUpSym = rngLookUpSym.Offset(1, 0)
Loop

'Protect Sheet
'ActiveSheet.Protect Password:="****"
'ActiveSheet.EnableSelection = xlUnlockedCells
Range("A1").Select
Application.ScreenUpdating = True

End Sub
___________________________

All I'm retrieving is the Company name and last price.

"Peter T" wrote:

"Peter T" wrote in message
< snip
Debug.Print bid, ask
' 30.0699996948242 30.0900001525879

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!



OK, now I'm getting same

' cells & VBA
30.3799991607666 30.3899993896484

on the web site
Bid 30.38
Ask 30.39

Looks like MS is on the up today!

Peter T


.