+ Reply to Thread
Results 1 to 3 of 3

Need Macro to pull data from list and create new worksheets for each result

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-10-2014
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2205 Build 16.0.15225.20368) 64-bit
    Posts
    102

    Need Macro to pull data from list and create new worksheets for each result

    I am trying to modify a macro I have that will help me use the macro below to help me go through a list of players to pull all the data tables mentioned below into one worksheet per player and then move on to the next player with their stats on the next worksheet. Right now I am going through each player one by one with the macro below and takes a lot of time and trying to see if there is a quicker solution.

    I have attached the list of players in the Excel file and then attached a notepad file of the query file that I used in Excel. Below is the code that I am currently using.

    Sub E()
    '
    ' E Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+E
    '
        ActiveWorkbook.Worksheets.Add
        With ActiveSheet.QueryTables.Add(Connection:= _
            "FINDER;C:\Users\mlaporte\Dropbox\NFL\NFL Players\E\All - E.iqy", Destination _
            :=Range("$A$1"))
            .Name = "All - E_1"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = _
            """defense"",""games_played"",""kicking"",""returns"",""passing"",""receiving_and_rushing"",""rushing_and_receiving"",""scoring"""
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End Sub
    Any help on how to speed up this process would be greatly appreciated. Thank you in advance.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Need Macro to pull data from list and create new worksheets for each result

    How would your code be linked to an individual player's name from the spreadsheet?
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need Macro to pull data from list and create new worksheets for each result

    Hello kingsdime29x,

    Welcome to the Forum!

    This was quite a challenge. Good news is you have a working solution. The workbook attached contains several macros to pull the stat data for each player on "Sheet1".

    As each player's stats are pulled, a new worksheet is added to the workbook. Each sheet is named after the player.

    The tables appear as the do on the web page, complete with working hyperlinks. The table are placed one on top of the other on the worksheet separated by a blank row.

    Sheet1 has a button to run the macros. Column "B" of the sheet has been reserved for error logging. Errors like connection problems to the site or duplicate player names in the list.

    Nollaig Chridheil!
    (Merry Christmas!)
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to pull data from 3 other worksheets, plus filtering help
    By Thunderer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2013, 05:35 PM
  2. Replies: 2
    Last Post: 05-06-2013, 08:53 AM
  3. Replies: 1
    Last Post: 07-13-2012, 12:11 PM
  4. Macro to create worksheets and transport data from Main list
    By LMoir in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-11-2012, 12:03 PM
  5. Create User form to pull from equipment list and fill in data
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2009, 02:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1