+ Reply to Thread
Results 1 to 2 of 2

Sort Value with Reference

  1. #1
    Registered User
    Join Date
    06-14-2017
    Location
    St Paul, Minnesota
    MS-Off Ver
    MS 2007
    Posts
    1

    Sort Value with Reference

    Hi.
    I have a list of Names (A3 thru A14) and individual counts (B3 thru B14) for each of these names.I would like to be able to have a list next to it (in D3 thru D14 and E3 thru E14) that reference the counts, but sort by the values, as the original list in columns A and B are sorted alphabetically.

    Currently, in E3 I have =B3 and so on down the column. I then would like to be able to sort the D/E section by the values in the E columns. Is there a way to do this? Currently, when I use the "sort by value" function it just changes around the D column list, but not the values in the E columns - those stay as they are a reference to the B column.

    Any thoughts would be greatly appreciated. I know with this small list it is easy to do it manually, but this will be a monthly thing with more rows being added so it would be ideal if there was a way to hit the sort button and have it do it.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Sort Value with Reference

    Welcome to the forum.

    There are a number of ways you can do this, but here's one of the simplest. It uses a helper column which you can put anywhere - for this explanation, I'm going to use column H.

    Leave columns A and B as they are.
    In the helper column H, put this in H3 and drag down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Now put these in D3 and E3, and drag down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The helper column ranks the counts in col B, then the formulae in D and E return the highest ranked name and count, next highest ranked, etc. The ROW()-2 part is because you're starting in row 3, so ROW()-2 gives 1, then 2, then 3, etc.
    You can hide column H if you want - the formulae in D and E will still work.

    If you change a number in column B, columns D and E will auto-sort.

    The formulae above go down to row 14, but you can just replace all the $14 references with $100 so you don't need to change them every time you add another month (or $1000 or $10000 if you want to future-proof it for longer). If you then drag down the formulae in H, D and E, you'll see errors appearing. You can hide these using IFERROR:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The "" gives blanks instead of errors - you could use "no data" or something like that if you prefer to see how far down you've dragged the formula.

    Attached is a file showing this working.
    Hope that helps.
    Last edited by Aardigspook; 06-14-2017 at 03:02 PM. Reason: Add missing formula tags
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

+ 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. [SOLVED] Sort Reference is Invalid
    By dhunton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2017, 09:03 PM
  2. The Sort Reference Is Not Valid
    By cbh35711 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2014, 08:56 PM
  3. Sort Reference is Not Valid
    By nickv02 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-07-2012, 04:43 PM
  4. Reference cell changes during sort
    By superboi in forum Excel General
    Replies: 3
    Last Post: 10-20-2011, 03:45 PM
  5. Automatically Sort By Reference Amount?
    By G in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  6. [SOLVED] Automatically Sort By Reference Amount?
    By Stefi in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 09-06-2005, 09:05 AM
  7. Automatically Sort By Reference Amount?
    By G in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-30-2005, 06:05 AM

Tags for this Thread

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