title: validate Addresses with USPS Macro -access DOM Explorer
body: <p>I am using below code to validate address in excel with USPS website. How can i retrieve the returned data from DOM Explorer section? Please see attached picture.</p>
  
  <p><a href="https://i.stack.imgur.com/wUGvX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wUGvX.png" alt="enter image description here"></a></p>
  
  <p>I am able to see the data from USPS return in IE but i cant retrieve the data in the code. Thank you for your help </p>
  
  <p>My code</p>
  
  <pre><code>Sub useClassnames()
      Dim element As IHTMLElement
      Dim elements As IHTMLElementCollection
      Dim ie As InternetExplorer
      Dim html As HTMLDocument
  
      Sheets("Address").Select
      erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
  
      'open Internet Explorer in memory, and go to website
  
      Set ie = New InternetExplorer
      ie.Visible = True
  
      ' Verify  addresses
      For r = 2 To 4
          myaddress = Cells(r, 1).Value
          mycity = Cells(r, 3).Value
          mystate = Cells(r, 4).Value
          myzipcode = Cells(r, 5).Value
          'myaddress = Range("a2").Value
          'mycity = Range("c2").Value
          'mystate = Range("d2").Value
          'myzipcode = Range("e2").Value
  
          'ie.navigate "https://tools.usps.com/go/ZipLookupAction!input.action"
          ie.navigate "https://tools.usps.com/zip-code-lookup.htm?byaddress"
  
          'Wait until IE has loaded the web page
          Do While ie.readyState &lt;&gt; READYSTATE_COMPLETE
              Application.StatusBar = "Loading Web page …"
              DoEvents
          Loop
  
          Set html = ie.document
  
          Set what = html.getElementsByName("tAddress")
          what.Item(0).Value = myaddress
          Set zipcode = html.getElementsByName("tCity")
          zipcode.Item(0).Value = mycity
          Set zipcode1 = html.getElementsByName("tState")
          zipcode1.Item(0).Value = mystate
  
          'Click the search button
          html.getElementById("zip-by-address").Click
  
          Do While ie.readyState &lt;&gt; READYSTATE_COMPLETE
              Application.StatusBar = "Loading Web page …"
              DoEvents
          Loop
  
          Set html = ie.document
  
          Set elements = html.getElementsByClassName("zipcode-result-address")
  
          For Each element In elements
              If element Like "*results*" Then
                  MsgBox element
              End If
          Next element
          'End
      Next r
  Set objie = Nothing
  Set ele = Nothing
  Set ie = Nothing
  End Sub
  </code></pre>