I'm new to Excel VBA programming and need some help to debug my code for web scraping some data off of Amazon.
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.
However, I keep getting the error:
User-Defined Type not Defined
I can't figure out where the bug is.
The code is listed below:
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/" & 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
Microsoft Internet Controlslibrary ?Dim pap As HTMLDocumentwill becomeDim pap As Objectwhen you use late binding but then you don't have to set references.IEas object variable,CreateObjectof ie application.