I am trying to get data from a website to my excel sheet but somehow I cannot navigate to the body of the table no matter what I do. Please see the website and the code below and tell me how can I get the latest values of 1Y, 2Y, ... , 10Y into my excel sheet. This is the code:
Option Explicit
Sub updatePKRV()
Dim ieobj As InternetExplorer
Dim iedoc As HTMLDocument
Dim htmlele As IHTMLElement
Dim HTMLRow As IHTMLElementCollection
Dim HTMLIT As IHTMLElement
Dim ws As Worksheet
Set ieobj = New InternetExplorer
ieobj.Visible = False
ieobj.navigate "https://fma.com.pk/index.php/pkrv/"
Do While ieobj.Busy = True Or ieobj.readyState <> READYSTATE_COMPLETE
Application.Wait Now + TimeValue("00:00:01")
Loop
Set iedoc = ieobj.document
Set htmlele = iedoc.getElementById("table_2")
'Set HTMLRow = htmlele.getElementsByTagName("tr")
Debug.Print htmlele.Children(0).textContent
End Sub
AFTER CHANGES
Option Explicit
Sub updatePKRV()
Dim ieobj As InternetExplorer
Dim iedoc As HTMLDocument
Dim htmlele As IHTMLElement
Dim HTMLRow As IHTMLElementCollection
Dim HTMLIT As IHTMLElement
Dim nodeList As Object, i As Long, arr()
Dim ws As Worksheet
Set ieobj = New InternetExplorer
ieobj.Visible = False
ieobj.navigate "https://fma.com.pk/index.php/pkrv/"
Do While ieobj.Busy = True Or ieobj.readyState <> READYSTATE_COMPLETE
Application.Wait Now + TimeValue("00:00:01")
Loop
Set iedoc = ieobj.document
Set htmlele = iedoc.getElementById("table_2")
Set nodeList = ieobj.document.querySelectorAll("#table_2 tr:nth-of-type(2) .column-date, #table_2 tr:nth-of-type(2) [class*=y]")
ReDim arr(1 To 11)
For i = 0 To 10
arr(i + 1) = nodeList.Item(i).innerText ''This is where is gets an error
Next
ActiveSheet.Cells(2, 1).Resize(1, UBound(arr, 2)) = arr
End Sub
You want the "header" first date column and then the first 10 of the years columns within the second row. You can use a css selector for that
#table_2 tr:nth-of-type(2) .column-date, #table_2 tr:nth-of-type(2) [class*=y]
This will retrieve a node list for the second row
tr:nth-of-type(2)
within the table with id table_2
#table_2
matching on the child with class column-date
.column-date
OR (,)
class that contains (*) the letter y (for year)
[class*=y]
Note:
I am matching on a single class of the multi-valued classes present.
The page is slow loading so you may need a timed loop to wait for elements to be fully loaded.
With that nodeList you want to go from 0 to 10 in order to get the first date field and the 10 first years.
Dim nodeList As Object, i As Long, arr()
Set nodeList = ie.document.querySelectorAll("#table_2 tr:nth-of-type(2) .column-date, #table_2 tr:nth-of-type(2) [class*=y]")
ReDim arr(1 To 11)
For i = 0 To 10
arr(i+1) = nodeList.item(i).innerText
Next
ActiveSheet.Cells(2,1).Resize(1, UBound(arr, 1)) = arr
Read about css selectors here: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
Quick browser test of matches and output:
2021-03-05 update
#table_2 tbody tr:nth-of-type(1) .column-date, #table_2 tbody tr:nth-of-type(1) [class*=y]
To take first row within table body (i.e. exclude header row and obtain latest date)
Related
Good afternoon,
First off....I know using ie for anything isn't great since its not being supported anymore.
I have figured out how to scrape a table but I need to have the table data to be placed in cell A5. I tried adding .range("A5") to parts of the code but haven't been able to get it to work. Please see code below:
Private Sub CommandButton3_Click()
'Clear the range before scraping
ActiveSheet.Range("A5:k5000").ClearContents
'Navigating to webpage
Dim ie As Object
Dim url As String
url = "https://www.myfueltanksolutions.com/validate.asp"
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate url
Do While ie.Busy: DoEvents: Loop
Do Until ie.readyState = 4: DoEvents: Loop
'Login credentails and submit
Dim idoc As MSHTML.HTMLDocument
Set idoc = ie.document
idoc.all.CompanyID.Value = "CompanyID"
idoc.all.UserId.Value = "UserID"
idoc.all.Password.Value = "Password"
idoc.parentWindow.execScript "submitForm();"
Do While ie.Busy: DoEvents: Loop
Do Until ie.readyState = 4: DoEvents: Loop
'Scrapging table
Dim tbl As HTMLTable
Set tbl = ie.document.getElementById("RecentInventorylistform")
Dim rowcounter As Integer
Dim colcounter As Integer
rowcounter = 1
colcounter = 1
Dim tr As HTMLTableRow
Dim td As HTMLTableCell
Dim th
Dim mySh As Worksheet
Set mySh = ThisWorkbook.Sheets("Sheet1")
For Each tr In tbl.getElementsByTagname("tr")
'Loop thru table cells
For Each td In tr.getElementsByTagname("td")
mySh.Cells(rowcounter, colcounter).Value = td.innerText
colcounter = colcounter + 1
Next td
colcounter = 1
rowcounter = rowcounter + 1
Next tr
'Log out and close website
ie.navigate ("https://www.myfueltanksolutions.com/signout.asp?action=rememberlogin")
ie.Quit
'Last updated and message box at completion
Range("N1") = Now()
MsgBox "Data Imported Successfully. Press Ok to Continue."
End Sub
Thank you so much for the help!
Do you want to start from cell A5? If so, you should change the value in mySh.Cells(rowcounter, colcounter).Value. Cell A5 is Cells(5, 1), so you should start from Cells(5, 1). You can try to change the code like this:
Dim rowcounter As Integer
Dim colcounter As Integer
rowcounter = 5
colcounter = 1
I am attempting to draw financial data from the Australian stock exchange (ASX). Specifically, the share registry for a particular company.
The website would be something like this (I say something because the ticker in the URL would change from firm to firm).
The HTML snippet I am looking at is:
<td class="ng-binding">COMPUTERSHARE INVESTOR SERVICES PTY LIMITED
<br>Yarra Falls, 452 Johnston Street, ABBOTSFORD, VIC, AUSTRALIA, 3067</td>
My overarching goal is to create a spreadsheet whereby I would have a list of Ticker Symbols and a macro would take that symbol, place it in the url and draw the adjacent Share Registry value into Excel. (In this case, COMPUTERSHARE INVESTOR SERVICES PTY LIMITED)
I tried to figure out how to use a variable url (I believe it involves Concatenation) and draw financial tables from websites.
I've settled on this tutorial that doesn't post the results into Excel, just presents it in a box. If I can results to post in the box that'll be a great first step.
Many tutorials use the IE object and from what I can gather, the use of XMLHttpRequest is far more efficient and nimble and considering I would have a large number of ticker symbols, would probably be best to use with regards to time.
Sub Get_Web_Data()
' TeachExcel.com
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim price As Variant
' Website to go to.
website = "https://www.asx.com.au/asx/share-price-research/company/BFG/details"
' Create the object that will make the webpage request.
Set request = CreateObject("MSXML2.XMLHTTP")
' Where to go and how to go there - probably don't need to change this.
request.Open "GET", website, False
' Get fresh data.
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
' Send the request for the webpage.
request.send
' Get the webpage response data into a variable.
response = StrConv(request.responseBody, vbUnicode)
' Put the webpage into an html object to make data references easier.
html.body.innerHTML = response
' Get the price from the specified element on the page.
price = html.getElementsByClassName("disclaimer disclaimer-company-info").Item(0).innerText
' Output the price into a message box.
MsgBox price
End Sub
I edited the code to present the only HTML class element that seems to be working for me, which is the disclaimer info at the bottom of the page. I gather that the use of html.getElementsByClassName is wrong in my scenario.
I have read that CSS Selectors might be applicable in this case and the use of 'children' (I think) as the info I am after (ng-binding) occurs numerous times throughout the table, so I gather I would need to direct the macro to select the nth instance.
I do not expect a completely written extract. Any hints and tips to point me in the right direction?
How about this?
Sub Web_Table_Option_Two()
Dim HTMLDoc As New HTMLDocument
Dim objTable As Object
Dim lRow As Long
Dim lngTable As Long
Dim lngRow As Long
Dim lngCol As Long
Dim ActRw As Long
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.Navigate "https://www.asx.com.au/asx/share-price-research/company/BFG/details"
Do Until objIE.ReadyState = 4 And Not objIE.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:03")) 'wait for java script to load
HTMLDoc.body.innerHTML = objIE.Document.body.innerHTML
With HTMLDoc.body
Set objTable = .getElementsByTagName("table")
For lngTable = 0 To objTable.Length - 1
For lngRow = 0 To objTable(lngTable).Rows.Length - 1
For lngCol = 0 To objTable(lngTable).Rows(lngRow).Cells.Length - 1
ThisWorkbook.Sheets("Sheet1").Cells(ActRw + lngRow + 1, lngCol + 1) = objTable(lngTable).Rows(lngRow).Cells(lngCol).innerText
Next lngCol
Next lngRow
ActRw = ActRw + objTable(lngTable).Rows.Length + 1
Next lngTable
End With
objIE.Quit
End Sub
If you want to specify the row, you can do that, and just grab the row number that you want/need.
Finally, if you want to loop through an array of stock tickers, use the code below.
Sub Web_Table_Option_Two()
Dim HTMLDoc As New HTMLDocument
Dim objTable As Object
Dim lRow As Long
Dim lngTable As Long
Dim lngRow As Long
Dim lngCol As Long
Dim ActRw As Long
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
Dim c As Range
Dim sht As Worksheet
Dim LastRow As Long
Dim wb As Workbook: Set wb = ThisWorkbook
Set sht = wb.Sheets("Stocks")
'find last used row in ColumnA
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
For Each c In Range("A2:A" & LastRow)
mystock = c.Value
objIE.Navigate "https://www.asx.com.au/asx/share-price-research/company/" & mystock & "/details"
Do Until objIE.ReadyState = 4 And Not objIE.Busy
DoEvents
Loop
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = mystock
ActRw = 1
Application.Wait (Now + TimeValue("0:00:01")) 'wait for java script to load
HTMLDoc.body.innerHTML = objIE.Document.body.innerHTML
With HTMLDoc.body
Set objTable = .getElementsByTagName("table")
For lngTable = 0 To objTable.Length - 1
For lngRow = 0 To objTable(lngTable).Rows.Length - 1
For lngCol = 0 To objTable(lngTable).Rows(lngRow).Cells.Length - 1
ThisWorkbook.ActiveSheet.Cells(ActRw + lngRow + 1, lngCol + 1) = objTable(lngTable).Rows(lngRow).Cells(lngCol).innerText
Next lngCol
Next lngRow
ActRw = ActRw + objTable(lngTable).Rows.Length + 1
Next lngTable
End With
Next c
objIE.Quit
End Sub
Before:
After:
I am able to download the inner text but not the exact table
I have tried using inner text and it only gave the text of the entire row
Private Sub CommandButton1_Click()
Dim i As Integer
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLAs As MSHTML.IHTMLElementCollection
Dim HTMLA As MSHTML.IHTMLElement
Dim tdocs As Object
Dim iframeDoc As MSHTML.HTMLDocument
IE.Visible = True
IE.navigate "https://portal.3gpp.org/#55931-tdocs"
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
Set HTMLDoc = IE.Document
Set tdocs = HTMLDoc.getElementsByName("lt-55931-tdocs")
tdocs(0).Click
Set iframeDoc = HTMLDoc.frames("dnn_ctr559_View_ctl00_ctl01_ctr596_ETSIFrame_htmModule").Document
Dim img As MSHTML.IHTMLElement
Set img = iframeDoc.getElementById("btnSearch")
img.Click
Application.Wait (Now + TimeValue("0:00:59")) '30sec
End If
For i = 1 To 2000
Set img = iframeDoc.getElementById("rgTdocList_ctl00__" & i)
Range("A" & i) = img.innerText
End Sub
I am getting the row in one column but i want them to be how it is originally on the web page
You can do something like this:
'...
'...
Application.Wait (Now + TimeValue("0:00:30")) '30sec
Dim tds, x
For i = 1 To 2000
Set img = iframeDoc.getElementById("rgTdocList_ctl00__" & i)
If img Is Nothing Then Exit For 'no more rows
Set tds = img.getElementsByTagName("td") '<< get cells for this row
'write out each cell's content
For x = 0 To tds.Length - 1
Cells(i, x + 1) = tds(x).innerText
Next x
Next i
I just discovered xml or xmlhttp and this is entirely new to me.
I am trying to create a macro wherein it would go through all the list of websites in column J starting at row 2 (header at row 1). Get the information that I want from each website, then display them in column K, which is right next to the websites where the information was taken from.
Column J has a list of websites, starting at J2. Let's say it would go all the way down to J10. From each website, there is a certain information I want to get, so the macro will visit the website at J2, get that information and paste it in K2, then visit the website in J3, paste that information in K3, and so on. I already have an existing list of website at column J, which also happens to be dynamic.
This is the current code that I have using IE that I want to convert into xml/xmlhttp.
Sub CommandButton1_Click()
Dim ie As Object
Dim lastrow As Integer
Dim i As Integer
Dim myURL As String
Dim sdd As String
Dim add As Variant
Dim html As Object
Dim mylinks As Object
Dim mylink As Object
Dim result As String
' Create InternetExplorer Object
Set ie = CreateObject("InternetExplorer.Application")
lastrow = Sheet1.Cells(Rows.Count, "J").End(xlUp).Row
For i = 2 To lastrow
myURL = Sheet1.Cells(i, "J").Value
' Hide InternetExplorer
ie.Visible = False
' URL to get data from
ie.navigate myURL
' Loop until page fully loads
Do While ie.readystate <> READYSTATE_COMPLETE
Loop
' Information i want to get from the URLs
sdd = ie.document.getelementsbyclassname("timeline-text")(0).innerText
' Format the result
add = Split(sdd, "$")
Range("K3") = add(1)
' Close InternetExplorer
ie.Quit
'Return to Normal?
ie.Visible = True
End
Next
' Clean up
Set ie = Nothing
Application.StatusBar = ""
End Sub
I am trying to get the "85100", not the $85,100
<span class="font-size-base font-normal">Est.</span>
<span itemprop="price" content="85100">
$85,100
</span>
I'm hoping you could help me with this problem.
Thank you in advance.
I would structure something like as follows, where the IE object is created outside the loop. You use css selectors throughout. You may need a timed loop to ensure element is present on page. Use a proper page load wait as shown.
Use an explicit worksheet name to put the worksheet in a variable to work with.
You might want to add a test that myURL has http/https in it as you may have blank cells in range and only want to work with likely urls values.
Option Explicit
Public Sub CommandButton1_Click()
Dim ie As Object, lastrow As Long, i As Long
Dim myURL As String, sdd As String, ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1") ' <change as required
Set ie = CreateObject("InternetExplorer.Application")
lastrow = ws.Cells(Rows.Count, "J").End(xlUp).Row
With ie
.Visible = False
For i = 2 To lastrow
myURL = ws.Cells(i, "J").Value
.navigate2 myURL
While .Busy Or .readyState < 4: DoEvents: Wend
sdd = .document.querySelector(".price").getAttribute("content")
ws.Cells(i, "K") = sdd
Next
.Quit
End With
'Application.StatusBar = ""
End Sub
With a timed loop:
Public Sub CommandButton1_Click()
Dim ie As Object, lastrow As Long, i As Long, t As Date, ele As Object
Const MAX_WAIT_SEC As Long = 10
Dim myURL As String, sdd As String, ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1") ' <change as required
Set ie = CreateObject("InternetExplorer.Application")
lastrow = ws.Cells(rows.Count, "J").End(xlUp).Row
With ie
.Visible = False
For i = 2 To lastrow
myURL = ws.Cells(i, "J").Value
.Navigate2 myURL
While .Busy Or .readyState < 4: DoEvents: Wend
t = Timer
Do
On Error Resume Next
Set ele = HTMLDoc.querySelector(".price")
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While ele Is Nothing
If Not ele Is Nothing Then
sdd = ele.getAttribute("content")
ws.Cells(i, "K") = sdd
End If
Next
.Quit
End With
'Application.StatusBar = vbnullstring
End Sub
I am looking to follow a series of URL's that are found in column A (example: https://www.ebay.com/itm/Apple-iPhone-7-GSM-Unlocked-Verizon-AT-T-TMobile-Sprint-32GB-128GB-256GB/352381131997?epid=225303158&hash=item520b8d5cdd:m:mWgYDe4a79NeLuAlV-RmAQA:rk:7:pf:0) and pull the following information from them:
- Title
- Price
- Description
I think there are multiple issues with my code... For one, I can't get the program to follow specific URL's listed in the Excel (only if I specify one within the code). Also, pulling multiple fields has given me issues.
Option Explicit
Public Sub ListingInfo()
Dim ie As New InternetExplorer, ws As Worksheet, t As Date
Dim i As Integer
i = 0
Do While Worksheets("Sheet1").Cells(i, 1).Value <> ""
Const MAX_WAIT_SEC As Long = 10
Set ws = ThisWorkbook.Worksheets("Sheet1")
With ie
.Visible = True
.Navigate2 Worksheets("Sheet1").Cells(i, 1).Value
While .Busy Or .readyState < 4: DoEvents: Wend
Dim Links As Object, i As Long, count As Long
t = Timer
Do
On Error Resume Next
Set Title = .document.querySelectorAll("it-ttl")
Set price = .document.querySelectorAll("notranslate")
Set Description = .document.querySelectorAll("ds_div")
count = Links.Length
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While count = 0
For i = 0 To Title.Length - 1
ws.Cells(i + 1, 1) = Title.item(i)
ws.Cells(i + 1, 2) = price.item(i)
ws.Cells(i + 1, 3) = Description.item(i)
Next
.Quit
i = i + 1
Loop
End With
End Sub
I would use late binding for MSXML2.XMLHTTP and set a reference to the Microsoft HTML Object Library for the HTMLDocument.
Note: querySelector() references the first item it finds that matches its search string.
Here is the short version:
Public Sub ListingInfo()
Dim cell As Range
With ThisWorkbook.Worksheets("Sheet1")
For Each cell In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
Dim Document As MSHTML.HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", cell.Value, False
.send
Set Document = New MSHTML.HTMLDocument
Document.body.innerHTML = .responseText
End With
cell.Offset(0, 1).Value = Document.getElementByID("itemTitle").innerText
cell.Offset(0, 2).Value = Document.getElementByID("prcIsum").innerText
If Not Document.querySelector(".viSNotesCnt") Is Nothing Then
cell.Offset(0, 3).Value = Document.querySelector(".viSNotesCnt").innerText
Else
'Try Something Else
End If
Next
End With
End Sub
A more elaborate solution would be to break the code up into smaller routines and load the data into an Array. The main advantage of this is that you can test each subroutine separately.
Option Explicit
Public Type tListingInfo
Description As String
Price As Currency
Title As String
End Type
Public Sub ListingInfo()
Dim source As Range
Dim data As Variant
With ThisWorkbook.Worksheets("Sheet1")
Set source = .Range("A1:D1", .Cells(.Rows.count, 1).End(xlUp))
data = source.Value
End With
Dim r As Long
Dim record As tListingInfo
Dim url As String
For r = 1 To UBound(data)
record = getListingInfo()
url = data(r, 1)
record = getListingInfo(url)
With record
data(r, 2) = .Description
data(r, 3) = .Price
data(r, 4) = .Title
End With
Next
source.Value = data
End Sub
Public Function getListingInfo(url As String) As tListingInfo
Dim ListingInfo As tListingInfo
Dim Document As MSHTML.HTMLDocument
Set Document = getHTMLDocument(url)
With ListingInfo
.Description = Document.getElementByID("itemTitle").innerText
.Price = Split(Document.getElementByID("prcIsum").innerText)(1)
.Title = Document.querySelectorAll(".viSNotesCnt")(0).innerText
Debug.Print .Description, .Price, .Title
End With
End Function
Public Function getHTMLDocument(url As String) As MSHTML.HTMLDocument
Const READYSTATE_COMPLETE As Long = 4
Dim Document As MSHTML.HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", url, False
.send
If .readyState = READYSTATE_COMPLETE And .Status = 200 Then
Set Document = New MSHTML.HTMLDocument
Document.body.innerHTML = .responseText
Set getHTMLDocument = Document
Else
MsgBox "URL: " & vbCrLf & "Ready state: " & .readyState & vbCrLf & "HTTP request status: " & .Status, vbInformation, "URL Not Responding"
End If
End With
End Function
There are a lot of things to fix in your code. It is late here so I will just give pointers (and update fully later) and working code below:
Declare all variables and use appropriate type
Review For Loops and how transpose can be used to create a 1d array of urls pulled from sheet to loop over
Review the difference between querySelector and querySelectorAll methods
Review CSS selectors (you are specifying everything as type selector when in fact you are not selecting by tag for the elements of interest; nor by your stated text)
Think about placement of your IE object creation and of your .Navigate2 to make use of existing object
Make sure to use distinct loop counters
Be sure not to overwrite values in sheet
Code:
Option Explicit
Public Sub ListingInfo()
Dim ie As New InternetExplorer, ws As Worksheet
Dim i As Long, urls(), rowCounter As Long
Dim title As Object, price As Object, description As Object
Set ws = ThisWorkbook.Worksheets("Sheet1")
urls = Application.Transpose(ws.Range("A1:A2").Value) '<= Adjust
With ie
.Visible = True
For i = LBound(urls) To UBound(urls)
If InStr(urls(i), "http") > 0 Then
rowCounter = rowCounter + 1
.Navigate2 urls(i)
While .Busy Or .readyState < 4: DoEvents: Wend
Set title = .document.querySelector(".it-ttl")
Set price = .document.querySelector("#prcIsum")
Set description = .document.querySelector("#viTabs_0_is")
ws.Cells(rowCounter, 3) = title.innerText
ws.Cells(rowCounter, 4) = price.innerText
ws.Cells(rowCounter, 5) = description.innerText
Set title = Nothing: Set price = Nothing: Set description = Nothing
End If
Next
.Quit
End With
End Sub
Here's an approach using Web Requests, using MSXML. It should be significantly faster than using IE, and I'd encourage you to strongly consider using this approach wherever possible.
You'll need references to Microsoft HTML Object Library and Microsoft XML v6.0 to get this working.
Option Explicit
Public Sub SubmitRequest()
Dim URLs As Excel.Range
Dim URL As Excel.Range
Dim LastRow As Long
Dim wb As Excel.Workbook: Set wb = ThisWorkbook
Dim ws As Excel.Worksheet: Set ws = wb.Worksheets(1)
Dim ListingDetail As Variant
Dim i As Long
Dim j As Long
Dim html As HTMLDocument
ReDim ListingDetail(0 To 2, 0 To 10000)
'Get URLs
With ws
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
Set URLs = .Range(.Cells(1, 1), .Cells(LastRow, 1))
End With
'Update the ListingDetail
For Each URL In URLs
Set html = getHTML(URL.Value2)
ListingDetail(0, i) = html.getElementByID("itemTitle").innertext 'Title
ListingDetail(1, i) = html.getElementByID("prcIsum").innertext 'Price
ListingDetail(2, i) = html.getElementsByClassName("viSNotesCnt")(0).innertext 'Seller Notes
i = i + 1
Next
'Resize array
ReDim Preserve ListingDetail(0 To 2, 0 To i - 1)
'Dump in Column T,U,V of existing sheet
ws.Range("T1:V" & i).Value = WorksheetFunction.Transpose(ListingDetail)
End Sub
Private Function getHTML(ByVal URL As String) As HTMLDocument
'Add a reference to Microsoft HTML Object Library
Set getHTML = New HTMLDocument
With New MSXML2.XMLHTTP60
.Open "GET", URL
.send
getHTML.body.innerHTML = .responseText
End With
End Function