View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel[_849_] joel[_849_] is offline
external usenet poster
 
Posts: 1
Default How to load specific range of html into Excel?


The code below extract the data in to individual lines


Sub HKEY()

URL =
"http://www.hkex.com.hk/eng/stat/dmstat/dayrpt/dqe100302.htm#HKB"


Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


'get web page
IE.Navigate2 URL
Do While IE.readyState < 4 Or _
IE.Busy = True

DoEvents
Loop

Set A = IE.document.getElementsByTagName("A")

CR = Chr(13)
LineFeed = Chr(10)
RowCount = 1
For Each itm In A
If UCase(itm.Name) = "HKB" Then
Data = itm.innertext
Do While Data < ""
If InStr(Data, CR) 0 Then
InputLine = Trim(Left(Data, InStr(Data, CR) - 1))
Data = Trim(Mid(Data, InStr(Data, LineFeed) + 1))
Else
InputLine = Data
Data = ""
End If
Range("A" & RowCount) = InputLine
RowCount = RowCount + 1
Loop
End If

Next itm


IE.Quit
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=192998

http://www.thecodecage.com/forumz