Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I modify the following code to direct its output
to a worksheet instead of to the immediate window? Private Const msROLLING_52_HIGH As String = "Rolling 52 Week High" Private Const msROLLING_52_LOW As String = "Rolling 52 Week Low" Private Const msPE_RATIO As String = "P/E Ratio" Private Const msDIVIDEND_RATE As String = "Indicated Dividend Rate" Sub GetStockValues() Dim ie As Object Dim s As String Dim nStart As Integer Dim nEnd As Integer Set ie = CreateObject("InternetExplorer.Application") With ie .Navigate "http://www.tse.ca/HttpController?GetPage=QuotesViewPage&D" _ & "etailedView=DetailedPrices&Language=en&QuoteSymbo l_1=BCE&x=18&y=7" Do Until Not .Busy And .ReadyState = 4 DoEvents Loop s = ie.Document.body.innertext .Quit End With Set ie = Nothing '/ get rolling 52-wk high nStart = InStr(1, s, msROLLING_52_HIGH, vbTextCompare) If nStart Then nStart = nStart + Len(msROLLING_52_HIGH) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msROLLING_52_HIGH & ": " & Mid$(s, nStart, _ nEnd - nStart) End If '/ get rolling 52-wk low nStart = InStr(1, s, msROLLING_52_LOW, vbTextCompare) If nStart Then nStart = nStart + Len(msROLLING_52_LOW) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msROLLING_52_LOW & ": " & Mid$(s, nStart, _ nEnd - nStart) End If '/ get p/e ratio nStart = InStr(1, s, msPE_RATIO, vbTextCompare) If nStart Then nStart = nStart + Len(msPE_RATIO) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msPE_RATIO & ": " & Mid$(s, nStart, _ nEnd - nStart) End If '/ get dividend rate nStart = InStr(1, s, msDIVIDEND_RATE, vbTextCompare) If nStart Then nStart = nStart + Len(msDIVIDEND_RATE) nEnd = InStr(nStart, s, vbCrLf) Debug.Print msDIVIDEND_RATE & ": " & Mid$(s, nStart, _ nEnd - nStart) End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
compare excel worksheet and output difference to new worksheet | Excel Discussion (Misc queries) | |||
Copy data output only to new worksheet. | Excel Discussion (Misc queries) | |||
Reference another worksheet as an output for IF formula? | Excel Discussion (Misc queries) | |||
How do I output the worksheet name in cell? | Excel Discussion (Misc queries) | |||
Making Find go through worksheet only once | Excel Discussion (Misc queries) |