+ Reply to Thread
Results 1 to 5 of 5

Can I sort a table based on a value calculated in a custom function?

  1. #1
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    Can I sort a table based on a value calculated in a custom function?

    I have a table containing an NFL football roster. I want to group players by position group and then sort the groups into a specific order. Right now I do it with a user function that places values into a hidden column and I sort the table by that column. If possible, I'd like to eliminate the hidden column.

    Below is the function, which effectively groups players in similar positions, and returns a number by which to sort them. The column on which I sort just contains a formula referring to the adjacent column with their position: =PositionSort(E24).

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: Can I sort a table based on a value calculated in a custom function?

    Scroll down in this link to Custom Sort

    https://edu.gcfglobal.org/en/excel2013/sorting-data/1/
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    Re: Can I sort a table based on a value calculated in a custom function?

    Thanks. I'm not sure that would also give me the grouping that I need. I forgot to mention that I sort by that column, then by name, so the position groups are also in alphabetic order.

    Also, my sorts of the table (I have several defined) are set up through a function defining which columns to use and their orderings, so I'd need to create and use this custom list in some way other than through the wizard/dialog boxess.

  4. #4
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    Re: Can I sort a table based on a value calculated in a custom function?

    Example workbook attached, containing the sorting functions used. Currently in the sort order I'm talking about - position group, then name. Normally, helper column F is hidden.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Can I sort a table based on a value calculated in a custom function?

    As far as I can judge, you need the helper column as there is no other way of achieving your objective where multiple positions have the same sort parameter.

    The helper column can be positioned anywhere "out of sight".
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as 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. Pivot Table Calculated Fields, Custom
    By Mr Stern 2 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-06-2021, 08:17 AM
  2. [SOLVED] Need a help with custom sort pivot table
    By jmoon9 in forum Excel General
    Replies: 0
    Last Post: 09-27-2021, 11:13 AM
  3. Sort table while keeping calculated numbers
    By ralle12 in forum Excel General
    Replies: 4
    Last Post: 02-18-2015, 02:23 PM
  4. [SOLVED] When does a Custom function get calculated?
    By tfurnivall in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-12-2013, 12:59 PM
  5. Sort a table by cells with a calculated value.
    By BlakeErnst in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-11-2012, 12:37 AM
  6. I need to sort based on a calculated field
    By r71lima in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-18-2012, 11:57 AM
  7. Custom Function not being auto calculated when cells change..help?
    By Alex Wolff in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-22-2005, 04:06 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