+ Reply to Thread
Results 1 to 11 of 11

Automatically sort specific data

  1. #1
    Registered User
    Join Date
    10-03-2014
    Location
    Utah
    MS-Off Ver
    2007
    Posts
    42

    Automatically sort specific data

    Assume I have this list:

    Sample.png

    Now, here's what I want to do (preferably with formulas and functions only - no macros). In column E, I would like to automatically sort the category name based on the amounts spent in each category. In other words it should be a simple list:

    Rent
    Car Payment
    Gas (Car)
    Power Bill
    Gas Bill
    Car Insurance

    This should automatically updated any time I update the amounts in column C. How do I do this? I'm at a complete loss...
    Last edited by Rheanna; 11-18-2014 at 05:06 PM.

  2. #2
    Registered User
    Join Date
    10-03-2014
    Location
    Utah
    MS-Off Ver
    2007
    Posts
    42

    Re: Automatically sort specific data

    I'm able to get the max category to show up by using this formula, but how would I duplicate this to show the second highest category (use the max formula excluding the categories that are entered before it)

    =if(C3=max($C$3:$C$8),B3,"")

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Automatically sort specific data

    See if this attached file does what you want...it sorts ascending.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-03-2014
    Location
    Utah
    MS-Off Ver
    2007
    Posts
    42

    Re: Automatically sort specific data

    Hm, it looks like it does what I want, but I have no idea what the formula means. Would you mind explaining the formula at all?

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Automatically sort specific data

    Quote Originally Posted by Rheanna View Post
    Hm, it looks like it does what I want, but I have no idea what the formula means. Would you mind explaining the formula at all?
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I'll need to start in the middle of the middle parenthesis like Excel does.

    This part:
    COUNTIF($B$2:$B$7,"<="&$B$2:$B$7) counts the number of values in column B that are less than or equal to each value. If you select
    just the "<="&$B$2:$B$7 part of the formula in the formula bar and press the F9 key you should see this: {"<=1200";"<=451";"<=152";"<=122.4";"<=125";"<=105.5"};

    then select all of this COUNTIF part and press F9 again and you should see this:

    {6;5;4;2;3;1}. That is the count of all values in the list that are less than or equal to the corresponding values. So how many values are less than or equal to 1200? Well, all of them including 1200. Those counts continue; they then sorted small to large with the ROWS($1:1) function assigning 1st, 2nd, 3rd ....etc smallest by assigning 1 rows, 2 rows, 3 rows....6 rows to each number in the {6;5;4;2;3;1} starting with the 1; they just happen to correspond with the positions of the 1st, 2nd.... smallest dollar amounts.

    Sorted these are then compared by the MATCH function back to another copy of COUNTIF($B$2:$B$7,"<="&$B$2:$B$7) and assigns index numbers that are then fed to the INDEX function that holds all your data...both columns.

    The formula used above is array entered into cell F2 by committing it with Ctrl + Shift + Enter; then use the fill handle to drag that cell down and then across to column G.

    The COLUMNS($A:A) part operates like the ROWS function assigning column index numbers to the INDEX function that tells it to fill in from the first column in your data through the second.

    Change the dollar amounts in column B and the formula adjusts accordingly....sorted by amounts with corresponding items following.

    It's more complicated to tell than it is to actually do. Just do the select/highlight of each individual step, in sequence, in your formula....starting from the inside working your way out as you go pressing the F9 key. In this way the formula kind of explains itself. It's tedious at first, but worth the effort if you want to understand how a formula is working...passing its values on to each successive function until it presents the solution.

    Whew......hope that helped.

    Edit: I just caught a problem with this solution. It is only half a solution. If one of your amounts is duplicated it will simply repeat the item in column A. There is a remedy....working on it.
    Last edited by FlameRetired; 11-18-2014 at 08:29 PM.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Automatically sort specific data

    Rheanna,

    To accommodate duplicate dollar amounts without duplicating the items here is the correction to my posts 3 and 5.

    It is done in two formulas; the one in column H should be entered first to avoid errors in the second one in column G (although it has error checks).

    Both these formulas are array-entered.....commit with Ctrl + Shift + Enter and fill down.

    In column H:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In column G:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The redone file is attached. This should work better.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-03-2014
    Location
    Utah
    MS-Off Ver
    2007
    Posts
    42

    Re: Automatically sort specific data

    This is working almost perfectly! (Thank you!) But I want it to have the highest number first, I tried changing "small" to "max", but that just messed everything up...

  8. #8
    Registered User
    Join Date
    10-03-2014
    Location
    Utah
    MS-Off Ver
    2007
    Posts
    42

    Re: Automatically sort specific data

    Oops. I change it to "Large" and it works perfectly! THANK YOU!!!!! :D

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Automatically sort specific data

    You're welcome. Glad it worked.

    P.S. Be sure to mark this thread as [SOLVED].

    BTW: lest I forget; the formula in column G is not my creation; I got the idea from micope21 in this thread Post #5:

    http://www.excelforum.com/excel-form...ng-column.html

    Sorry for the oversight.
    Last edited by FlameRetired; 11-19-2014 at 04:54 PM.

  10. #10
    Registered User
    Join Date
    10-03-2014
    Location
    Utah
    MS-Off Ver
    2007
    Posts
    42

    Re: Automatically sort specific data

    Dumb question... how do I mark this as solved?

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Automatically sort specific data

    Quote Originally Posted by Rheanna View Post
    Dumb question... how do I mark this as solved?
    Not a dumb question...

    Just above your original post there is a bar that has a Thread Tools drop-down. Click that and mark Solved.

+ 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. Replies: 0
    Last Post: 10-15-2014, 03:44 PM
  2. [SOLVED] Automatically copy specific data from one spreadsheet to a different specific worksheet
    By kelcowcow in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2014, 01:47 AM
  3. How can i automatically sort data
    By Losguapos1 in forum Excel General
    Replies: 1
    Last Post: 10-10-2013, 08:36 AM
  4. Automatically send an email from excel with specific data on specific date.
    By Angela1607 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2009, 08:11 AM
  5. automatically Data sort
    By s.w in forum Excel General
    Replies: 1
    Last Post: 11-14-2007, 10:42 AM

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