+ Reply to Thread
Results 1 to 10 of 10

Sorting a range into another range

Hybrid View

James C Sorting a range into another... 03-12-2013, 11:06 AM
martindwilson Re: Sorting a range into... 03-12-2013, 11:18 AM
Pete_UK Re: Sorting a range into... 03-12-2013, 11:20 AM
James C Re: Sorting a range into... 03-12-2013, 11:27 AM
Pete_UK Re: Sorting a range into... 03-12-2013, 11:55 AM
James C Re: Sorting a range into... 03-12-2013, 12:46 PM
Pete_UK Re: Sorting a range into... 03-12-2013, 01:10 PM
James C Re: Sorting a range into... 03-12-2013, 01:32 PM
Pete_UK Re: Sorting a range into... 03-12-2013, 01:35 PM
flemingkr Re: Sorting a range into... 04-18-2013, 12:55 AM
  1. #1
    Registered User
    Join Date
    07-22-2004
    Posts
    89

    Sorting a range into another range

    Hello all.

    I have a range A1:A2
    these two cells contain formulas
    each formula outputs a numeric value
    I want to have range B1:B2 that contains the values, but sorted, descending.
    Can someone propose formulas for B1, B2 that does this?

    Thanks!

    J

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sorting a range into another range

    only two cells?
    b1=(max(a1:a2)
    b2= min(a1:a2)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Sorting a range into another range

    Put this in B1:

    =LARGE($A$1:$A$2,ROWS($1:1))

    Then copy the formula into B2 - the second term will become ROWS($1:2).

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    07-22-2004
    Posts
    89

    Re: Sorting a range into another range

    Ah, elegant solution Pete, but, alas, I didnt draft my example properly, its going to be utilized for 3 or more cells
    J

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Sorting a range into another range

    I expected it would do. Just change the range to suit how much data you have in column A, e.g.:

    =LARGE($A$1:$A$100,ROWS($1:1))

    then copy down.

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    07-22-2004
    Posts
    89

    Re: Sorting a range into another range

    NICE!
    And what do I change in the formula IF I want to change from ascending to descending?
    J

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Sorting a range into another range

    Use SMALL instead of LARGE.

    Hope this helps.

    Pete

  8. #8
    Registered User
    Join Date
    07-22-2004
    Posts
    89

    Re: Sorting a range into another range

    PERFECT!
    THanks.

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Sorting a range into another range

    You're welcome - thanks for feeding back.

    How about spreading a few "stars" around for the people who help you?

    Pete

  10. #10
    Registered User
    Join Date
    04-05-2012
    Location
    Colo Spgs CO
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Sorting a range into another range

    I have a similar challenge, and getting nowhere. In my case the range is two columns, the first of which is text and the 2nd is number. Data looks like:


    A 5
    A 10
    C 5
    D 10
    A 18
    D 5
    D 24


    This range is intended for data entry by a person, and I prevent duplicate rows but have no control over order. To do an INDEX() and MATCH() on this data, I need the numeric values for any given alpha value to be descending. So, the desired copy of this range would look like:


    C 5
    D 24
    D 10
    D 5
    A 10
    A 5


    I've shown the rows for any given text value to be contiguous, but that doesn't matter--but all rows for 'D' must be sorted desc on the numeric value, all rows for 'A' sorted desc on the corresponding number, etc.

    The ONLY reason I think I need to do this is to satisfy the range criteria for INDEX(), where, for a given text string (e.g., 'A'), I need to find the smallest number that's >= to some criteria number I give it.
    What I think would be a 1 minute problem in SQL has taken me all afternoon and I still can't 'get it'. Suggestions?

    I see this as creating/maintaining a sorted 'copy' of a range, where the sort instructions are 'first on column 1 then on column 2 desc', but that viewpoint is keeping me from getting anywhere.
    Last edited by flemingkr; 04-18-2013 at 01:02 AM.

+ 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