title: Excel VBA Web Scraping
body: <p>I'm new to Excel VBA programming and need some help to debug my code for web scraping some data off of Amazon. </p>
  
  <p>On my sheet1, I am listing the asins of products and trying to use this code to complete the URL to land onto the product page, then will the sales rank of the product via class ID or another html tag. </p>
  
  <p>However, I keep getting the error:</p>
  
  <blockquote>
    <p>User-Defined Type not Defined</p>
  </blockquote>
  
  <p>I can't figure out where the bug is.</p>
  
  <p>The code is listed below:</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Row = Range("azAsin").Row And Target.Column = Range("azAsin").Column Then
       Dim IE As New InternetExplorer
       IE.Visible = True
       IE.Navigate "https://www.amazon.com/dp/" &amp; Range("azAsin").Value
      Do
       DoEvents
      Loop Until IE.readyState = READYSTATE_COMPLETE
      Dim pap As HTMLDocument
      Set pap = IE.document
      Dim sDoc As String
      sDoc = Doc.getElementsById("SalesRank")
  
      MsgBox sDoc
      End If
  End Sub
  </code></pre>