PDA

View Full Version : Is it possible to get excel to pull data from websites?



shonuff18
03-01-2012, 12:16 PM
Is it possible to get excel to pull data from websites and automatically update on excel? (Is it possible to get excel or some program to update from online.)

So if I was looking at basketball stats I could have it automatically update every day from basketball-reference.com/ and pull all 30 NBA teams + all players + all opponents stats. From there I would want it to calculate a few different stats that I have created that are not currently published such as Points Per Shot (PPS) instead of Field Goal % (FG%).

If possible can someone please write a code that would allow me to do this. Thank you.

Kenneth Hobs
03-01-2012, 07:08 PM
That is a big project for someone to help with in a forum for free. I am not sure that anyone would have time for that much work. If it is worth someone doing that much , you will need to provide lots more details.

Macros are automations so you need to be able to do it manually first and then explain it. That is the good thing about this forum, it lets you post files. The more you help the helper, the better the help you get.

mdmackillop
03-02-2012, 10:12 AM
Here's sample code to get a table of data into excel.

Sub gethtmltable()
Dim objWeb As QueryTable

With Sheets("KBItems")
.Range("A:C").ClearContents
Set objWeb = .QueryTables.Add( _
Connection:="URL;http://www.vbaexpress.com/kb/kblist.php", _
Destination:=.Range("A1"))
With objWeb
.WebSelectionType = xlSpecifiedTables
.WebTables = "13" ' Identify your HTML Table here
.Refresh BackgroundQuery:=False
.SaveData = True
End With
.Range("B1").ColumnWidth = 30
.Range("C1").ColumnWidth = 40
.Columns("B").Font.ColorIndex = 5
.Columns("B").Font.Underline = xlUnderlineStyleSingle
End With
Set objWeb = Nothing
End Sub

shonuff18
03-06-2012, 06:02 PM
Thank you so much for all the help. I am really sorry, but I am unfamiliar with coding so I don't know what things mean in your sample code so I wouldn't know how to replace them appropriately for my problem. Is it possible to explain what each thing means?

My goal is to be able to go to basketball-reference.com/teams/ and go through every team for every year and pull the "Team and Opponent Statistics".