+ Reply to Thread
Results 1 to 2 of 2

Auto Sort Data

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    HOWN
    MS-Off Ver
    Excel 2010
    Posts
    5

    Talking Auto Sort Data

    Still learning VBA so please bare with me..

    Trying to Create a sheet that will sort students grades based on rank and name.

    Breif example of what im trying to do:

    Student Test 1 Test 2 AVG Rank
    Bob 81 89 85 2
    Sue 91 95 95 1
    Joe 79 71 75 3

    I would like the sheet to sort based on rank and name in descending order while keeping the whole row for each student in tact. So in this case Sue would move up to the top with all her test scores and average. I would like to use a button to do this as well.

    Here is the code I have been trying
    Please Login or Register  to view this content.
    No changes are made to the sheet after running this Macro

    Thank you so much for your help!
    Grades Order.xlsm
    Last edited by Leith Ross; 07-14-2015 at 02:17 PM. Reason: Add Attachment

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Auto Sort Data

    Some help and then some comments:
    your Keys need to be the entire range (e.g. Key1:=Range("E1:E3"))

    - If you get stuck on how something should work, try recording a macro. It is not always the best way to achieve something, but it can help you see the parameters and what excel expects.
    - Why put this in a worksheet_change event? Maybe you plan on doing other things within the handler, but, generally, event handlers should be avoided unless truly needed and they may cause some user consternation (i.e. every time a name is added, this will sort, but what if the person also wanted to include grades? Now, they have to find the name in the table and add them). It breaks the flow of data input.
    - You could just use a table. Lots of nice features. It auto-expands as you add data to the bottom of the table or to the right. There are easy buttons in each header that you can press to sort or filter each column. It can have a table footer which shows Totals, averages, and other calculations. It will not auto-sort every time you add a name, but it will take care your request to 'use a button to do this as well'. Just select a cell in your table and hit Ctrl-T and choose the full range you want to use (I also recommend you create column headers).
    Last edited by Pauleyb; 07-14-2015 at 03:08 PM.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

+ 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. Auto Sort Data
    By Redfeather in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2013, 12:56 PM
  2. Auto Sort data
    By Redfeather in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 12-04-2013, 09:29 AM
  3. Replies: 3
    Last Post: 10-08-2013, 02:59 PM
  4. Need help- Auto Sort data and auto subtotal
    By lesliewheeler in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-28-2013, 07:11 AM
  5. [SOLVED] Help with auto sort data
    By glamint in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-15-2012, 01:26 AM
  6. Auto Sort of Data
    By gavster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2009, 07:00 AM
  7. auto data sort ?
    By Avenger556 in forum Excel General
    Replies: 2
    Last Post: 09-27-2008, 09:32 PM
  8. Sort Data only/auto add row
    By su_jumptd in forum Excel General
    Replies: 3
    Last Post: 03-14-2008, 12:16 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