So I made this Macro to open up IE and enter in the data for columns a and b, then extract info from the website. The problem I am having is that since I set "a" as an integer, it will just keep going through row 500 or so. What I really need it to do is stop when there are no more addresses. Can someone help me with this? Attached is the spreadsheet with the code in it.

Thanks!GeoTax Query.xlsm

Also here is the code

Sub GeoTax()


Dim a As Integer


For a = 1 To 500



Set ie = CreateObject("internetexplorer.application")
ie.Visible = False
ie.Navigate "http://www.geotax.com/USTaxLookup/"

Do While ie.ReadyState <> 4 Or ie.Busy = True
DoEvents
Loop



If ie.document.Title = "GeoTAX - Free Instant Sales and Use Tax Rates" Then
ie.document.getelementbyid("tbAddress").Value = Range("Address")(a + 1)
ie.document.getelementbyid("tbLastline").Value = Range("Zip")(a + 1)
ie.document.all("tbTaxValue").Value = "100"
ie.document.getelementbyid("btnGO").Click
Do While ie.ReadyState <> 4 Or ie.Busy = True

DoEvents
Loop

If Left(ie.document.getelementbyid("__VIEWSTATE").Value, 15) <> "/wEPDwUIOTEyOTE" Then



Range("Muni")(a + 1).Value = ie.document.getelementbyid("lblmuni").innerText
Range("County")(a + 1).Value = ie.document.getelementbyid("lblcounty").innerText
Range("State")(a + 1).Value = ie.document.getelementbyid("lblState").innerText
Range("County")(a + 1).Value = ie.document.getelementbyid("lblcounty").innerText
Range("State")(a + 1).Value = ie.document.getelementbyid("lblState").innerText
Range("SalesTax")(a + 1).Value = ie.document.getelementbyid("lblSalesTax").innerText
Range("UseTax")(a + 1).Value = ie.document.getelementbyid("lblUseTax").innerText

End If

End If


' ie.Quit



Next a



End Sub