+ Reply to Thread
Results 1 to 2 of 2

Website data elements into Excel spreadsheet using VBA

  1. #1
    Registered User
    Join Date
    05-20-2015
    Location
    England
    MS-Off Ver
    2007
    Posts
    12

    Website data elements into Excel spreadsheet using VBA

    Hi,

    I am new to this site and to Excel VBA.

    I have a spreadsheet which contains two columns of UK postcodes(about 1,500).

    The column A contains "from" and column B contains "To"
    I want the vba to go to WWW.AA.com and insert the From/To postcodes into the route finder to obtain the Distance and Travel time.

    I have managed to access the AA website using VBA and by hardcoding the From/To I have managed to get the route and time.

    However, I would like to extract the Distance and Travel time I think the elements are called "routeDistanceValue" for Distance and Travel time "routeTimeDistance" from the website back into spreadsheet. I haven't been able to find out how to this action.

    Following this action, I want the codes to go down a row and start the query again and put the next line's postcodes into the query.

    Please can you help me with the code below




    Macro 1 - simply checked that there are two postcodes, if there are two, it moves onto macro2

    Sub macro1()
    'test for previous postcode

    If ActiveCell.Offset(0, -1) = "" Then ActiveCell.Offset(1, 0).Select Else Call macro2



    End Sub


    Sub macro2()
    'This will call the the AA website and runs query


    Dim ie As Object
    Dim postcodefrom As String
    Dim postcodeto As String


    Let postcodefrom = ActiveCell.Offset(0, -1)
    Let postcodeto = ActiveCell.Offset(0, -2)


    Set ie = CreateObject("Internetexplorer.Application")
    ie.Visible = True

    ie.Navigate "http://www.theaa.com/route-planner/index.jsp?fromPlace=CV32 6RN&toPlace=WR12 7LJ"

    the ie.Navigate requires changing to allow for the new postcodes. I have setup postcodefrom and postcodeto in preparation for this. But how do you adapt the code.

    Any assistance will be very much appreciated.

    Thanks in advance

    Alan

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Website data elements into Excel spreadsheet using VBA

    Maybe you could try a more direct approach

    http://www.postcodeanywhere.co.uk/Su...ve/Distance/1/

    by using a bespoke web service.
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Parse data from website to Excel using DIV elements
    By KK33317 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2014, 02:29 PM
  2. [SOLVED] Taking Data from a Website to a Spreadsheet
    By lmiguel13 in forum Excel General
    Replies: 3
    Last Post: 06-21-2013, 11:27 AM
  3. data extraction from website to excel spreadsheet
    By wyldjokre69 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-28-2012, 07:01 AM
  4. [SOLVED] how to grab data from a website into an excel spreadsheet?
    By flyingdutch06 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-21-2012, 09:27 AM
  5. Extract data from website in an Excel Spreadsheet
    By sh_obaid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2011, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1