cstewart28
New Member
- Joined
- May 4, 2016
- Messages
- 7
I trying to get a list the of items based on the class name list-group-item on this page (https://www.cattle.com/markets/archive.aspx?code=TV_LS153) and then populate them across column fields and I need the dates to stay in the same form as yyyy-mm-yy format. My spreadsheet in column A hold the TV_LS153 information.
I keep getting an error at line "Sheets("Sheet2").Range("B" & y).Value = element.innerText"
Sub GetClassNames()
'dimension (declare or set aside memory for) our variables
Dim HTML As HTMLDocument
Dim objIE As Object
Dim y As Integer 'integer variable we'll use as a counter
Dim result As String 'string variable that will hold our result link
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "https://www.cattle.com/markets/archive.aspx?code=" & Range("A1").Text
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
y = b
Set HTML = objIE.document
Set elements = HTML.getElementsByClassName("list-group-item")
For Each element In elements
If element.className = "list-group-item" Then
Sheets("Sheet2").Range("B" & y).Value = element.innerText
y = y + 1
End If
Next element
End Sub
I keep getting an error at line "Sheets("Sheet2").Range("B" & y).Value = element.innerText"
Sub GetClassNames()
'dimension (declare or set aside memory for) our variables
Dim HTML As HTMLDocument
Dim objIE As Object
Dim y As Integer 'integer variable we'll use as a counter
Dim result As String 'string variable that will hold our result link
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "https://www.cattle.com/markets/archive.aspx?code=" & Range("A1").Text
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
y = b
Set HTML = objIE.document
Set elements = HTML.getElementsByClassName("list-group-item")
For Each element In elements
If element.className = "list-group-item" Then
Sheets("Sheet2").Range("B" & y).Value = element.innerText
y = y + 1
End If
Next element
End Sub