Skip to content Skip to sidebar Skip to footer

Vba Excel For Each Row In Table Match Cell In Spreadsheet With Cell In Webpage Table

This is kind of a repost to reorganize my question but: I'm trying to match my spreadsheets cell B1 text with all the cells in the 10th column of a table on a webpage. If theres a

Solution 1:

We could have more chance for success with this:

Sub sof20255214WebpageCell()

  Dim colRows AsObject
  Dim objDataGrid AsObject
  Dim xobj1 AsObject
  Dim element
  Dim xcel AsObject

  Dim IE

  Set IE = CreateObject("InternetExplorer.Application")
  IE.navigate "http://www.example.com/DataGridPage.php"While (IE.Busy Or IE.READYSTATE <> 4)
    DoEvents
  Wend

  Set objDataGrid = IE.Document.getElementById("DataGridReservations")
  Set colRows = objDataGrid.getElementsByTagName("tr")

  For Each element In colRows
    Set xcel = element.getElementsByTagName("td")
    If Range("B1").Text = xcel.Item(9).innerText Then
      Range("H" & (ActiveCell.Row)) = xcel.Item(3).innerText
    Else
      Range("H" & (ActiveCell.Row)) = "0"
    End IfExitFor
  Next

  IE.Quit

End Sub

Anyway, we cannot use this (BAD):

Setxcel= colRows.getElementsByTagName("td")

As colRows is a collection of rows, but not a single row object. Nevertheless, you can use this (Good):

Setxcel= colRows.Item(0).getElementsByTagName("td")

Post a Comment for "Vba Excel For Each Row In Table Match Cell In Spreadsheet With Cell In Webpage Table"