Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extract data from web

HI,

I would like to extract data from below given site through web query. It
needs to input date of query. HOw this can be possible through VBA?. I
tried to record macro and run it but not successful.

The web address is;
http://www.moneycontrol.com/stocks/m...eals/index.php

Thank you for your hlp.

  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extract data from web

Hi Joel,

Genius.... what a code!! I could not understand head or tail of codes....
from where it takes data from and stores in a variable and writes back into
excel.... superb way of coding. Thanks for your prompt reply.

The codes given by you gives current day's report but if i want to have
previous days data by entering my preferred date and then extract the data
similar to previous one, into excel sheet. HOw can i do it.

Thanks once again.

"joel" wrote:


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

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extract data from web


I will take a look toight if there is a way to get previous day data.


You don't need to put data into a variable, you can read data in the
webpage and put it directly into excel. The text is in a property
called innertext on the webpage


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

Microsoft Office Help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract matching data from large data file (csv) Utahstew Excel Programming 8 April 14th 08 03:57 AM
Tying to extract all data from a pivot pulling from external data Ted Urban Excel Discussion (Misc queries) 3 September 14th 07 10:50 AM
extract data from web Scott Excel Programming 1 August 14th 07 02:19 PM
Extract data mohitmahajan Excel Programming 0 October 7th 04 05:41 AM
extract data John Collins[_4_] Excel Programming 5 December 9th 03 06:18 PM


All times are GMT +1. The time now is 03:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"