Question: So I will start by saying that I am very new to VBA. I am trying to extract data from the table on [this page](https://rotogrinders.com/team-stats/nba-earned?site=draftkings). I haven't acomplished much as far as the code goes so take it easy on me. I am looking for some direction on how to approach it and if it can be done, which I believe it can. If anyone is able to help guide me in the right direction that would be much appreciated.

```
Sub rgnbateamstats()

Dim appIE As Object
Set appIE = CreateObject("internetexplorer.application")

With appIE
.navigate "https://rotogrinders.com/team-stats/nba-earned?site=draftkings"
.Visible = True
End With

Do While appIE.Busy
DoEvents
Loop

Set allRowOfData = appIE.document.getElementById("proj-stats")

```

Not really sure where to go from here or if I'm even on the right track.

Answer: 
Whilst the table layout may appear a little odd, it actually just needs a 180 in thinking. You can grab the columns by the class name and then simply loop the rows; rather than the usual looping of rows then columns.

I use a [CSS class selector](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) to grab the columns with `querySelectorAll` i.e. I target the columns by their class name. This returns a `nodeList` containing each of the columns. Below is an example of the first two columns (admittedly abbr is not visible). Each row within a column is in a `div` so if I loop the columns I get the rows within each column by grabbing the associated `div` tag collection. Then I simply loop those to write out. 

[![enter image description here](https://i.stack.imgur.com/d3itE.png)](https://i.stack.imgur.com/d3itE.png)

```
Option Explicit
Public Sub GetInfo()
    Dim IE As New InternetExplorer, iColumns As Object, iRow As Object, i As Long, j As Long, r As Long, c As Long
    Application.ScreenUpdating = False
    With IE
        .Visible = True
        .navigate "https://rotogrinders.com/team-stats/nba-earned?site=draftkings"

        While .Busy Or .readyState < 4: DoEvents: Wend

        Set iColumns = .document.querySelectorAll(".rgt-col")

        With ThisWorkbook.Worksheets("Sheet1")
            For i = 0 To iColumns.Length - 1
                c = c + 1: r = 0
                Set iRow = iColumns.item(i).getElementsByTagName("div")
                For j = 0 To iRow.Length - 1
                    r = r + 1
                    .Cells(r, c) = iRow(j).innerText
                Next
            Next
        End With
        Application.ScreenUpdating = True
        .Quit
    End With
End Sub

```

---

References:

VBA > Tools > References > Microsoft Internet Controls

Or change to late bound with:

```
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")

```
Try this part for extracting first column

```
Set allrowofdata = appIE.document.getElementById("proj-stats")

Set newobj = allrowofdata.getElementsByClassName("rgt-col")(0)

For Each x In newobj.Children
r = r + 1
Cells(r, 1).value = x.innerText
Next x

```