View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_595_] joel[_595_] is offline
external usenet poster
 
Posts: 1
Default Extract data from web


Try this

Sub CNBC()

URL = "http://www.moneycontrol.com/stocks/marketstats/" & _
"blockdeals/index.php"

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


'get web page
IE.navigate2 URL & Ticker
Do While IE.readystate < 4 Or _
IE.busy = True

DoEvents
Loop

Do While IE.document Is Nothing
DoEvents
Loop


ColCount = 1
RowCount = 1

Set Table = IE.document.getelementsbytagname("Table")
For Each tbl In Table
If Left(tbl.innertext, 7) = "BSE/NSE" Then
Set BlockTbl = tbl
End If
Next tbl

For Each Row In BlockTbl.Rows
ColCount = 1
For Each cell In Row.Cells

Cells(RowCount, ColCount) = cell.innertext
ColCount = ColCount + 1
Next cell
RowCount = RowCount + 1
Next Row

IE.Quit
End Sub


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

Microsoft Office Help