I wrote a code from various sources around the internet that pulls data from a website with a static url with the exception of 2 fields. I had this code working at one point but my computer crashed and i lost it and had to re write it.
What the code does:
I have a list of APN Numbers and i want to paste them in the A column then it pulls land, improvements and total value for the buildings and puts them in columns b, c, and d.
Now when i do this it does the first record but then gives me a "run-time error '462': the remote server machine does not exist or is unavailable" on the ie.navigate "http://tax.ocgov.com/tcweb/detail_sec.asp?ReqParcel=" & APN & "&StreetNo=&Direction=&StreetName=&APN=" & APN & "&Suffix=00&CmpRevDte=79889283&RollTypCde=Secured&Code=A&StSuffix=&City=&Unit=&s=1&p=1&t=&TaxYr=2011" line
here is the whole code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
For i = 1 To Range("a6000").End(xlUp).Row
Dim APN As String
APN = Range("a" & i).Value
If Target.Row = Range("A1").Row And _
Target.Column = Range("A1").Column Then
Dim Ie As New InternetExplorer
Ie.Visible = False
Ie.navigate "http://tax.ocgov.com/tcweb/detail_sec.asp?ReqParcel=" & APN & "&StreetNo=&Direction=&StreetName=&APN=" & APN & "&Suffix=00&CmpRevDte=79889283&RollTypCde=Secured&Code=A&StSuffix=&City=&Unit=&s=1&p=1&t=&TaxYr=2011"
Do
DoEvents
Loop Until Ie.readyState = READYSTATE_COMPLETE
Dim doc As HTMLDocument
Set doc = Ie.document
STD = Trim(doc.getElementsByTagName("TD")(195).innerText)
STD2 = Trim(doc.getElementsByTagName("TD")(203).innerText)
STD3 = Trim(doc.getElementsByTagName("TD")(215).innerText)
Ie.Quit
Cells(i, 2).Value = STD
Cells(i, 3).Value = STD2
Cells(i, 4).Value = STD3
End If
Next i
End Sub
can anyone give me some insight on this. I am new to vba so you might have to explain it in "English" for me. Even though I got it to work at one point I still have no idea what half this code actually means.
thanks in advance.
What the code does:
I have a list of APN Numbers and i want to paste them in the A column then it pulls land, improvements and total value for the buildings and puts them in columns b, c, and d.
Now when i do this it does the first record but then gives me a "run-time error '462': the remote server machine does not exist or is unavailable" on the ie.navigate "http://tax.ocgov.com/tcweb/detail_sec.asp?ReqParcel=" & APN & "&StreetNo=&Direction=&StreetName=&APN=" & APN & "&Suffix=00&CmpRevDte=79889283&RollTypCde=Secured&Code=A&StSuffix=&City=&Unit=&s=1&p=1&t=&TaxYr=2011" line
here is the whole code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
For i = 1 To Range("a6000").End(xlUp).Row
Dim APN As String
APN = Range("a" & i).Value
If Target.Row = Range("A1").Row And _
Target.Column = Range("A1").Column Then
Dim Ie As New InternetExplorer
Ie.Visible = False
Ie.navigate "http://tax.ocgov.com/tcweb/detail_sec.asp?ReqParcel=" & APN & "&StreetNo=&Direction=&StreetName=&APN=" & APN & "&Suffix=00&CmpRevDte=79889283&RollTypCde=Secured&Code=A&StSuffix=&City=&Unit=&s=1&p=1&t=&TaxYr=2011"
Do
DoEvents
Loop Until Ie.readyState = READYSTATE_COMPLETE
Dim doc As HTMLDocument
Set doc = Ie.document
STD = Trim(doc.getElementsByTagName("TD")(195).innerText)
STD2 = Trim(doc.getElementsByTagName("TD")(203).innerText)
STD3 = Trim(doc.getElementsByTagName("TD")(215).innerText)
Ie.Quit
Cells(i, 2).Value = STD
Cells(i, 3).Value = STD2
Cells(i, 4).Value = STD3
End If
Next i
End Sub
can anyone give me some insight on this. I am new to vba so you might have to explain it in "English" for me. Even though I got it to work at one point I still have no idea what half this code actually means.
thanks in advance.