Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Location: Melbourne
Posts: 5
Default Macro to download house prices from web

Hi,

I am very new to VBA and wanting to write a code to automate the download of housing data for suburbs, vacancy rates etc from various websites.

So far I have the following code, but already I know this is very inefficient and cannot work out the best way to extract the relevant data.


Private Sub btnGetData_Click()

Dim IE As New InternetExplorer
IE.navigate "http://whatpostcode.com.au/postcodes/" & Range("State").Value & "/" & Range("suburb").Value
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE

Dim Doc As HTMLDocument
Set Doc = IE.document
Dim sh3 As String
sh3 = Trim(Doc.getElementsByTagName("h3")(0).innerText)
Range("Postcode").Value = sh3
IE.Quit

Dim IE2 As New InternetExplorer
IE2.Visible = True
IE2.navigate "http://www.rs.realestate.com.au/cgi-bin/rsearch?a=sp&s=" & Range("state").Value & "&u=" & Range("suburb").Value
Do
DoEvents
Loop Until IE2.readyState = READYSTATE_COMPLETE
Dim Doc2 As HTMLDocument
Set Doc2 = IE2.document
Dim sth As String
sth = Trim(Doc2.getElementsByTagName("th")(5).innerText)
IE2.Quit

End Sub


Basically user inputs a suburb name and state on the worksheet. The code then uses these and finds the postcode from the first website.

Then code navigates to a second website and I want it to extract the median house price data from tables on this website. Ideally, I would like the code to set a new worksheet for a new suburb search and save this data in a list. If the user searches the same suburb, any new data will be appended to the end of the table to get a long history.

My issue comes from extracting the data from the table. How to automate this in as few lines of code as possible, and how to make VBA recognise if this is a new suburb search or existing sheet, and how to append new data to end of list.
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
function to download stock prices into Excel with 2007 newfy Excel Worksheet Functions 1 March 6th 10 11:36 PM
How do you download reatime stock prices into a spreadsheet? Buzz Bennett Excel Worksheet Functions 2 February 26th 07 03:12 PM
updating historical prices log (macro?) Darren Excel Programming 1 January 27th 06 02:48 PM
Use a multiplier to change List Prices to Net prices Dangada Excel Worksheet Functions 1 July 6th 05 06:31 AM


All times are GMT +1. The time now is 09:07 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"