Consulting

Results 1 to 4 of 4

Thread: Is it possible to get excel to pull data from websites?

  1. #1

    Is it possible to get excel to pull data from websites?

    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.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Here's sample code to get a table of data into excel.
    [VBA]
    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
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    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".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •