# Getting inner text of table VBA/Selenium



## noctash (Dec 28, 2022)

I am trying to copy the values of table cells on a web page to excel. The table has a variable number of rows, but I only need the first two columns.

Currently, I am using the following code, but it is taking a LONG time, a second or two for each row, which can take a long time for a big table.
Is there a faster way to do this that will copy over only the first two columns?


```
Dim Driver As New Selenium.ChromeDriver
Set Driver = CreateObject("Selenium.ChromeDriver")

Driver.Timeouts.ImplicitWait = 1

Driver.Start baseUrl:="https://website.com"
Driver.get "/table"
Dim Table As Selenium.WebElement
Set Table = Driver.FindElementById("tableID")

    Dim AllRows As Selenium.WebElements
    Dim SingleRow As Selenium.WebElement
    Dim AllRowCells As Selenium.WebElements
    Dim SingleCell As Selenium.WebElement
    Dim OutputSheet As Worksheet
    Dim RowNum As Long, ColNum As Long
    Dim TargetCell As Range
    Set OutputSheet = ThisWorkbook.Worksheets("REFERENCE")

    Set AllRows = Table.findelementsbytag("tr")
        For Each SingleRow In AllRows
            RowNum = RowNum + 1
            Set AllRowCells = SingleRow.findelementsbytag("td")

            If AllRowCells.Count = 0 Then
                Set AllRowCells = SingleRow.findelementsbytag("th")
            End If

            For Each SingleCell In AllRowCells
                ColNum = ColNum + 1
                 Set TargetCell = OutputSheet.Cells(RowNum, ColNum)
                 TargetCell.Value = SingleCell.Text
  
            Next SingleCell
                ColNum = 0
        Next SingleRow
```


----------



## TedX (Dec 28, 2022)

I've never seen this before, but I did a quick Google to see about it and came up with this next sentence. I'm wondering if you change your 1 for 0, if it will make any difference. Regardless of that, I wish you all the best.  🙏 



> An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements *(if) they are not immediately available*. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.


----------

