Hey Everyone,
I've created a VBA code that will automatically populate fields within the website, but I'm having troubles trying to figure out the code to select a state from the dropdown list on the website. I also can't seem to figure out the code to then click on the "Find" button once the fields are populated. Here's what I have so far that doesn't seem to be working:
Any help would be much appreciated. Thanks!
I've created a VBA code that will automatically populate fields within the website, but I'm having troubles trying to figure out the code to select a state from the dropdown list on the website. I also can't seem to figure out the code to then click on the "Find" button once the fields are populated. Here's what I have so far that doesn't seem to be working:
Code:
Sub Find_ZipCode()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "https://tools.usps.com/go/ZipLookupAction!input.action?mode=1&refresh=true"
IE.Navigate URL
Do
DoEvents
Loop Until IE.readyState = 4
Call IE.document.getElementById("tAddress").SetAttribute("value", "217 E Rockingham Dr")
Call IE.document.getElementById("tCity").SetAttribute("value", "Eagle")
With IE.document.getElementById("sState")
For i = 0 To .Length - 1
If .Item(i).Value = "ID - Idaho" Then
.Item(i).Selected = True
Exit For
End If
Next
End With
Call IE.document.getElementById("Zzip").SetAttribute("value", "83616")
Set AllHyperLinks = IE.document.getElementsByTagName("A")
For Each hyper_link In AllHyperLinks
If ID = "lookupZipFindBtn" Then
hyper_link.Click
Exit For
End If
Next
End Sub
Any help would be much appreciated. Thanks!