Results 1 to 7 of 7

VB only solving first row

Threaded View

  1. #1
    Registered User
    Join Date
    02-06-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    4

    VB only solving first row

    I am new to all this and am looking for some help. I have a sheet with two columns of postcodes (column 1 and 3) and looking for each row to return the distance in column 5 and time in the 6. I have managed to get the code below working but it only returns the distance and time for the first row of the sheet. The code is below and if anyone can help I would be most greatful. I need it keep running down as far as there are rows with entries in column 1. Thank you in advance.

    Sub Macro2()
    '
    ' Macro2 Macro
    '
    
    '
     c01 = Cells(1, 1)
     c02 = Cells(1, 3)
     
     With New XMLHTTPRequest
      .Open "Get", "https://maps.google.co.uk/maps?f=d&source=s_d&saddr=" & c01 & "&daddr=" & c02
      .send
      Do
       DoEvents
      Loop Until .readyState = 4
                    
      c03 = .responsetext
      .abort
     End With
        
     If InStr(c03, "mi</span>") <> 0 Then
      c03 = Mid(c03, InStr(c03, "mi</span>") - 6, 40)
      If Val(c03) = 0 Then c03 = Mid(c03, 2)
      If Val(c03) = 0 Then c03 = Mid(c03, 2)
            
      c04 = Split(c03, "<")(0)
      c03 = Split(Split(c03, ">")(2), "<")(0)
      
      Cells(1, 5) = c04
      Cells(1, 6) = c03
     End If
    End Sub
    Last edited by phras81; 03-14-2014 at 12:30 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Solving for PMT
    By Davidns in forum Excel General
    Replies: 0
    Last Post: 05-20-2011, 06:18 PM
  2. solving for combinations
    By stevenpaul in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2009, 04:23 AM
  3. Pls help me in solving
    By shanprimsw in forum Excel General
    Replies: 1
    Last Post: 05-18-2009, 02:37 AM
  4. Replies: 6
    Last Post: 12-09-2007, 11:09 AM
  5. Solving as x?
    By gpktm in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-14-2007, 12:42 AM

Tags for this Thread

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