Help important html data into spreadsheet live from website

srallen3

New Member
Joined
Feb 26, 2016
Messages
31
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:

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
4,126
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,518
Messages
5,625,269
Members
416,086
Latest member
CaptainGD

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
Top