+ Reply to Thread
Results 1 to 9 of 9

Baseball Q - Return Multiple Matches in Column/VLookup?

  1. #1
    Registered User
    Join Date
    03-17-2007
    Posts
    17

    Return Multiple Matches in Column/VLookup/Advanced Filtering

    With baseball coming up, I am using a sheet I found on seanlahman.com for the basis of a school excel project.

    The original spreadsheet contains records going back to 1870. I want career stats for only players who played in 2006 but can't figure out how to do this without copy-pasting for the next week straight. I created a small sample of this massive file to help visualize. Sheet 1 contains records from the original file. Sheet 2 contains the desired output which is essentially identical to sheet 1 except that it does not contain any records for non-current players.

    This spreadsheet comes as part of an Access database as well so it may be easier to use the query feature to pull this info but I am not familiar with Access. I understand that I would probably use the criteria function.

    As for the spreadsheet itself, I was able to isolate a list of playerIDs for those who played in 2006 and then used vlookup on those cells which only returned either the first or last year of stats from the raw data depending on how it was sorted at the time. Not sure how to return multiple matches in multiple rows using vlookup.

    If any of this is unclear, I can clarify. I'm guessing the answer is going to be easy for someone here.

    Thanks in advance and enjoy St. Patty's Day.
    Last edited by TENNISMAN; 03-17-2007 at 01:16 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526
    Hi there,

    If you are using excel you could use the auto filter

    heres a great read on AutoFilter

    http://www.contextures.com/xlautofilter01.html

  3. #3
    Registered User
    Join Date
    03-17-2007
    Posts
    17
    Quote Originally Posted by davesexcel
    Hi there,

    If you are using excel you could use the auto filter

    heres a great read on AutoFilter

    http://www.contextures.com/xlautofilter01.html
    Thanks for the tip but I don't think autofilter will help me here because I am not looking to filter for specific years, rather I am looking to filter out various years based on the player's situation.

    It would be quite simple to tell Excel to filter for data from 2006 or filter out data for years prior to 1975. But to ask Excel to filter out career data for players who did not play in 2006 while preserving career data for those who DID play in 2006, that's a little more complex.

    It might sound more confusing than it actually is; I imagine there to be a simple solution but I have only taught myself Excel and have had no training.

  4. #4
    Registered User
    Join Date
    03-17-2007
    Posts
    17
    A way to think of this in terms of customer payments since baseball might be confusing...

    Customers under Column A
    Year for which payments were made under Column B
    Months for which payments were made under Columns C-N (12 months)
    Total payments for the year under Column O

    Over the 10 year history of the business, we have had hundreds of customers come and go and want to analyze payment data for just our current or most recent customers. We believe that we can do this by filtering only only for those customers who made payments during 2006. Keep in mind however that we want to show all of their payment data (and show all columns A:O at that) as long as they have been a customer, not just 2006 figures.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526
    Quote Originally Posted by TENNISMAN
    A way to think of this in terms of customer payments since baseball might be confusing...

    Customers under Column A
    Year for which payments were made under Column B
    Months for which payments were made under Columns C-N (12 months)
    Total payments for the year under Column O

    Over the 10 year history of the business, we have had hundreds of customers come and go and want to analyze payment data for just our current or most recent customers. We believe that we can do this by filtering only only for those customers who made payments during 2006. Keep in mind however that we want to show all of their payment data (and show all columns A:O at that) as long as they have been a customer, not just 2006 figures.
    Thanks, I am working on it, almost have it

  6. #6
    Registered User
    Join Date
    03-17-2007
    Posts
    17
    Quote Originally Posted by davesexcel
    Thanks, I am working on it, almost have it
    Appreciate the help. I have a nutrition spreadsheet I'd like to post up on here as thanks but do not know what forum I would throw that under.

  7. #7
    Registered User
    Join Date
    03-17-2007
    Posts
    17
    Eureka!

    Had to use Access to accomplish this. Remember how I said I was able to isolate a list of the players who had served in 2006? (just not all their data!! ) I saved that list as its own .xls file and imported into the existing Access database. I created a relationship between the master list and that list and then queried the list with just 2006 players. Didn't have to enter any criteria in the query.

    As for using just Excel to accomplish this, it is still a mystery.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Filter and copy to another sheet

    After Noon

    Here's a sample workbook, goto sheet three and follow the instruction,

    I have yet to perfect the <=2006, so I had to use top 17, just a number I came up with

    The Macro is called

    BaseBallFilter

    the macro to paste the data into sheet 3 is called

    CopyFilter

    Both are located in Module 2

    Good luck, I am sure I will think about details I have missed later
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-17-2007
    Posts
    17
    Nice job on this. It takes out a step from what I did in allowing someone to analyze a specific player or customer if you will. My original desire was to just get rid of all of the retired players (or past customers) out of the database and then begin an analysis from there though this is quite helpful in its own right.

    Thanks again for all your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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