+ Reply to Thread
Results 1 to 38 of 38

How to make items rise to the top? [Google Sheets]

  1. #1
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    How to make items rise to the top? [Google Sheets]

    I would like to make people with rank "Council" to automatically rise to the top, people with rank "Enforcer" to go after them, followed by "Member" and then "Trialist". How do I do this?

    0b9a8862f2e4750dfbd70a6a1a286e92.png

    http://www.excelforum.com/attachment...4947-how-to-co

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to make items rise to the top?

    You could try a macro like this

    Please Login or Register  to view this content.
    Right click on tab "Red Roster", then click on "View Code". In the new windows that opends past this code.

    This will sort based on the value in the C, it's possible to add a second sort key for instance if you wish to sort on both position and name.

    As this macro is written it will only be activated by a change in range C3:C27.


    Alf

  3. #3
    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: How to make items rise to the top?

    Add a custom list: https://support.office.com/en-sg/art...b-ba213ec2fd61
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top?

    Quote Originally Posted by shg View Post
    Any idea how to do this in Google Docs?

  5. #5
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top?

    Quote Originally Posted by Alf View Post
    You could try a macro like this

    Please Login or Register  to view this content.
    Right click on tab "Red Roster", then click on "View Code". In the new windows that opends past this code.

    This will sort based on the value in the C, it's possible to add a second sort key for instance if you wish to sort on both position and name.

    As this macro is written it will only be activated by a change in range C3:C27.


    Alf
    Can't find how to do this in Google Sheets....

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to make items rise to the top?

    I'm sorry but as I've never worked with Google sheets I can't help you any further.

    Alf

  7. #7
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top?

    Quote Originally Posted by Alf View Post
    I'm sorry but as I've never worked with Google sheets I can't help you any further.

    Alf
    All the formulas are the same, it's just there's no code thing. There's a powerful script editor though.

    What language is that bit of code in?

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top?

    Do you have to sort on the "status" column, or would you be willing to add a helper column and use that to sort on? I could envision a simple lookup table that associates the value 1 with "council", 2 with "enforcer", and so on. then use a lookup function (like VLOOKUP() to add these values to a helper column, then use that column as the sort key.

    lookup table
    Please Login or Register  to view this content.
    lookup function =VLOOKUP(status_text,lookup_table,2,false)
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to make items rise to the top?

    What language is that bit of code in?
    Code is written in Visual Basic

    Alf

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to make items rise to the top? [Google Sheets]

    I have moved this thread because the question is specific to Google Sheets.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  11. #11
    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: How to make items rise to the top?

    Code is written in Visual Basic
    Visual Basic for Applications -- similar, but not the same.

  12. #12
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: How to make items rise to the top?

    Visual Basic for Applications -- similar, but not the same.
    Yes, so right you are. My bad.


    Googling a bit and this is what I found

    While macros are currently not supported in Google Docs, Sheets, or Forms, you can extend the capabilities of documents, spreadsheets, and forms by adding custom menus, dialogs, and sidebars with Google Apps Script, a simple yet powerful scripting language based on JavaScript. In Google Sheets, Apps Script also lets you write custom spreadsheet functions.
    So it seems macro is out.

    I downloaded your "Red Roster" sheet and opened in Excel 2010. Have added the macro and will upload the file. If you have access to Excel 2010 you can download the file from the forum and test to see if a macro like this was what you were looking for.

    Alf
    Attached Files Attached Files
    Last edited by Alf; 12-08-2015 at 04:17 PM.

  13. #13
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top?

    Quote Originally Posted by MrShorty View Post
    Do you have to sort on the "status" column, or would you be willing to add a helper column and use that to sort on? I could envision a simple lookup table that associates the value 1 with "council", 2 with "enforcer", and so on. then use a lookup function (like VLOOKUP() to add these values to a helper column, then use that column as the sort key.

    lookup table
    Please Login or Register  to view this content.
    lookup function =VLOOKUP(status_text,lookup_table,2,false)
    I would be willing to add a helper column, how do I start doing this?

    I'm new to this, sorry.
    Last edited by Idler; 12-08-2015 at 05:00 PM.

  14. #14
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    1) Select a safe, out of the way location for the lookup table.
    2) Enter the lookup table.

    3) Select a column for the helper column (I would probably put it in the column to the right of "steam name".
    4) Enter the VLOOKUP() function (MS's help file for this function: https://support.office.com/en-us/art...8-93a18ad188a1 I'm reasonably certain that Google tries to make their sheets compatible with Excel's use of these common, basic functions) Pay attention to your use of relative and absolute references, then copy the formula down the column.

    5) Execute sort according Google docs/sheets protocol.

  15. #15
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Quote Originally Posted by MrShorty View Post
    1) Select a safe, out of the way location for the lookup table.
    2) Enter the lookup table.

    3) Select a column for the helper column (I would probably put it in the column to the right of "steam name".
    4) Enter the VLOOKUP() function (MS's help file for this function: https://support.office.com/en-us/art...8-93a18ad188a1 I'm reasonably certain that Google tries to make their sheets compatible with Excel's use of these common, basic functions) Pay attention to your use of relative and absolute references, then copy the formula down the column.

    5) Execute sort according Google docs/sheets protocol.
    Sorry, what is a lookup table, and how is it formatted? Sorry

  16. #16
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    A lookup table is a table that is used in a lookup function. In the help file, after the description of each argument, is a picture that shows a basic lookup table, with last name, first name, and birthday. As I tried to indicate, your lookup table only needs two columns -- status and sort priority.

  17. #17
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    I used =VLOOKUP(council,T5:U9,2,false)

    And put this:
    a7c161b47f19bbc254452dfe29f0e074.png
    as the lookup table.

    However, I got
    d238e067c9bd7afefabd9eba7e7839c5.png

    and

    8aaf7499de1b3a5500b46d30f3a21814.png

  18. #18
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    Assuming google sheets behaves like Excel:
    council (without quotes) is the name for a named range, which, I assume you have not defined.
    "council" (with quotes) is the text string "council", which, I expect is what you want.
    Based on what I saw in your first post, I would expect this argument to be a reference to same row in the "status" column (column C?), instead of using the text literal. So =vlookup(C2,$T$5:$U$9,2,false) Note the use of absolute and relative references so that the reference to the status column will change as the formula is copied, but the reference to the lookup table will not change.

  19. #19
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Sorry, I'm completely baffled as to what I'm supposed to do.

    Can you fill in the lookup table for me and then I'll work out how it works?
    Thanks so much for all this help.
    RED Roster (5).xlsx

  20. #20
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    I started the additions. You will need to copy the formula in G3 down the column. You will also need to finish filling in the lookup table (T7:U15).
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    This really isn't helping me... All that happens is that a "1" appears. I'm not quite sure that you know what I want to do...

    MrShortyCopy of RED Roster (5) (1).xlsx

  22. #22
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    Maybe I don't. I thought that the end goal was to be able to sort the list so that "council" members would be at the top of the list, followed by "enforcers", and so on. Is that correct?

    You are correct that this formula simply returns a number. If done correctly, you should then be able to use this column of numbers as your first sort key. All the 1's should rise to the top, followed by the 2's, and so on.

    Is that what you are ultimately looking to do, or is there something I am missing?

  23. #23
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Quote Originally Posted by MrShorty View Post
    Maybe I don't. I thought that the end goal was to be able to sort the list so that "council" members would be at the top of the list, followed by "enforcers", and so on. Is that correct?

    You are correct that this formula simply returns a number. If done correctly, you should then be able to use this column of numbers as your first sort key. All the 1's should rise to the top, followed by the 2's, and so on.

    Is that what you are ultimately looking to do, or is there something I am missing?
    That is what I'm looking for, but I don't know what a sort key is?

  24. #24
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    A sort key is the column that you want to use for sorting a list. I don't know how these dialogs work in Google Sheets. In Excel, when you click on the "sort" command, a dialog comes up that asks what column you want to use first for sorting the list and how do you want to use that column (ascending or descending). I assume Google sheets will have a similar dialog. In this case, you will use this helper column in column G in the sort dialog when it asks you what column to sort by. If they are sorted in ascending order, then the 1's (which are tied to the "council" value in column C by the VLOOKUP() function) should end up at the top, followed by the 2's and so on.
    Last edited by MrShorty; 12-11-2015 at 03:01 PM.

  25. #25
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    OK, nice. I tried to do that, but it's not working...

    MrShortyCopy of RED Roster (5) (2).xlsx

  26. #26
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    There seems to be something funny happening when you copy the VLOOKUP() formula down. Instead of using the expected relative reference to the status value (same row column C in each cell), it is changing the reference to row 2. Double check how you are copying the VLOOKUP() formula and make sure that it is correctly adjusting the relative reference.

  27. #27
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Quote Originally Posted by MrShorty View Post
    There seems to be something funny happening when you copy the VLOOKUP() formula down. Instead of using the expected relative reference to the status value (same row column C in each cell), it is changing the reference to row 2. Double check how you are copying the VLOOKUP() formula and make sure that it is correctly adjusting the relative reference.
    I'm just copy and pasting it...

  28. #28
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    When you paste it, what is Google doing with the C3 reference in the formula? Spreadsheets (not just Excel) should generally make these references "relative", meaning they move relative to the cell they are pasted from and to. (https://support.office.com/en-us/art...es_in_formulas ). So when you copy this formula from G3 to G4, the reference should change from C3 to C4 as well, and so on down the column. Google does not appear to be doing that. It might be tedious, but if Google does not want to copy according to standard spreadsheet conventions, then you will need to go in and manually correct those references in the VLOOKUP() formula.

  29. #29
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: How to make items rise to the top? [Google Sheets]

    The formulas starting in row six are (all):
    =VLOOKUP(C2,$T$7:$U$10,2,FALSE), C2 is the header cell (status)
    in row three it is correct:=VLOOKUP(C3,$T$7:$U$15,2,FALSE).
    As it is copied down the column, C3 must increment, C4, C5, ...
    Ben Van Johnson

  30. #30
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Ah. So I've done that, and I got this. Is this right?

    RED Roster (6).xlsx

  31. #31
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    That's what I had in mind. Now, you should be able to execute your sort command, using this column as your first "sort by" (or whatever Google calls it) column.

  32. #32
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    What should I select to sort? Which set of cells?

  33. #33
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    Whichever cells you want included in the sort. My first guess would be B3:G17.

  34. #34
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Alright, I sorted it but when I make a new member, with the status council, it doesn't rise to the top.

  35. #35
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    I'm not sure I understand. What steps are you taking when you add a new member, and what do you expect to happen at each step? When adding a new member, I would expect the following steps:
    1) Add data to the bottom of the table.
    2) Execute sort command.
    3) Table should sort, with new entry(ies) finding its(their) proper place in the table.
    Are you expecting your table to sort automatically without manually executing the sort command?

  36. #36
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Quote Originally Posted by MrShorty View Post
    I'm not sure I understand. What steps are you taking when you add a new member, and what do you expect to happen at each step? When adding a new member, I would expect the following steps:
    1) Add data to the bottom of the table.
    2) Execute sort command.
    3) Table should sort, with new entry(ies) finding its(their) proper place in the table.
    Are you expecting your table to sort automatically without manually executing the sort command?
    That is what I was expecting, but how do I execute the sort command?

  37. #37
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to make items rise to the top? [Google Sheets]

    When I go into Google sheets, I see that there is a "sort range" command on the Data menu. I would select the desired range then use the Data menu -> Sort range command. In this dialog, you should be able to indicate which column you wish to sort by and which direction you want to sort (ascending or descending).

  38. #38
    Registered User
    Join Date
    12-06-2015
    Location
    London, England
    MS-Off Ver
    Google Sheets
    Posts
    25

    Re: How to make items rise to the top? [Google Sheets]

    Ah, I don't really want to do that every time, so I'm going to give up on this.

    Thanks everyone for the help, really appreciate it!

+ 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: 1
    Last Post: 01-25-2014, 02:10 PM
  2. Want to make a 'Google' like search tool - Is it possible?
    By Wanting2Excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-11-2012, 05:56 PM
  3. Make Money From Google
    By Joe [email protected] in forum Excel General
    Replies: 0
    Last Post: 04-25-2006, 02:45 AM
  4. Make Money From Google
    By Joe [email protected] in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 04-25-2006, 02:45 AM
  5. Make Money From Google
    By Joe [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2006, 02:45 AM
  6. [SOLVED] Make Money From Google
    By Joe [email protected] in forum Excel General
    Replies: 0
    Last Post: 04-25-2006, 02:40 AM
  7. [SOLVED] Make Money From Google
    By Joe [email protected] in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 04-25-2006, 02:40 AM
  8. Make Money From Google
    By Joe [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2006, 02:40 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