Help important html data into spreadsheet live from website

srallen3

New Member
Joined
Feb 26, 2016
Messages
32
Office Version
  1. 2019
Platform
  1. Windows
I need to import data from: 2020 NBA Team Defense Stats. This is an updated file of NBA statistics. However, if you go to that website, you will see that it is currently filtered to "total". If you click that button, you will see the option "Per Game" pops up. That is the data that I need to pull, not the Total data. What would be the easiest way to do that?

Edit: Also, would it be possible for the data pulled to be sorted in alphabetical order? This can be done on the website by click the team column twice.
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I did it with Chrome:

VBA Code:
Public driver As New ChromeDriver
Sub D_Fence()
Dim pt As WebElement, ac, el As WebElement, LO As ListObject
driver.get "https://www.lineups.com/nba/team-stats/defense"
Set pt = driver.FindElementById("ngb-dd-modeDropdown")
pt.Click
Set el = driver.FindElementByXPath("/html/body/app-root/div[3]/app-nba-team-stats-module/" & _
"app-team-stats/div/div/div[4]/div/div/app-dropdown[3]/div/div/div[1]/div/label")
el.Click
Set pt = driver.FindElementByXPath("/html/body/app-root/div[3]/" & _
"app-nba-team-stats-module/app-team-stats/div/div/div[5]/div/table")
pt.AsTable.ToExcel Sheets("sheet7").[b150]
Application.CutCopyMode = False
Sheets("sheet7").ListObjects.Add(xlSrcRange, [b150].CurrentRegion, , xlYes).Name = "Table8"
Set LO = Worksheets("Sheet7").ListObjects("Table8")
LO.Sort.SortFields.Clear
LO.Sort.SortFields.Add2 key:=Range("Table8[[#All],[TEAM]]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
With LO.Sort
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = 1
    .Apply
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top