+ Reply to Thread
Results 1 to 6 of 6

Sort FUnction in VBA

  1. #1
    Registered User
    Join Date
    09-24-2014
    Location
    Bronx, NY
    MS-Off Ver
    2013
    Posts
    2

    Post Sort FUnction in VBA

    I'm working on a project that uses Excel VBA to sort a data set of all NFL players. The data set contains 536 players in no particular order. What I have to do is sort the data by position. So the dataset looks something like this:

    QB Peyton Manning $100,000 25pts
    WR Marquees Colston $50,000 20pts
    D Seattle Seahawks $10,000 9pts
    QB Drew Brees $100,000 30 pts

    Etc....

    What I have to do is first select all of the players who's position is "QB"and list them, then "RB" and so on. I've been trying to select a Range if the Value of any of the cells in the range start with "QB" and paste them into another worksheet. Not too much luck so far though. Can anyone help me out?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Sort FUnction in VBA

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Sort FUnction in VBA

    Use Excel>Preferences (I understand its called Options on Windows machines) to create a Custom List of your position abbreviations and sort the position column choosing that list from the Sort > Order > Custom List.

    Note that it will sort only the items in the list. If your list is "QB", "WR", "D", it will not work on entries like "QB Manning", "QB" will have to be in its own column.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    09-24-2014
    Location
    Bronx, NY
    MS-Off Ver
    2013
    Posts
    2

    Re: Sort FUnction in VBA

    Book1.xlsm

    Here is a sample workbook. There are 536 players on the "Before" sheet, I only sorted 9 manually because it would be a bit time consuming. How can I make a macro to sort this for me?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Sort FUnction in VBA

    There's a fantasy football draft workbook at https://app.box.com/s/sdwzfoop41o6knld22vt.

    Can you post your data?
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Sort FUnction in VBA

    Quote Originally Posted by mwmackay View Post
    Attachment 349307

    Here is a sample workbook. There are 536 players on the "Before" sheet, I only sorted 9 manually because it would be a bit time consuming. How can I make a macro to sort this for me?
    Do you mean like this. (See attached file.)

    macro to sort by position.xlsm

+ 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. sort function to sort for bell curve
    By Kuby in forum Excel General
    Replies: 4
    Last Post: 12-16-2005, 02:55 PM
  2. Complicated sort function with sort and sum
    By Matz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  3. [SOLVED] Complicated sort function with sort and sum
    By Matz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  4. [SOLVED] Complicated sort function with sort and sum
    By Matz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. Complicated sort function with sort and sum
    By Matz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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