+ Reply to Thread
Results 1 to 14 of 14

Sort by Teams across

  1. #1
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,375

    Sort by Teams across

    Hi,

    I'm trying to convert all my code to Paul Kelly type of .CurrentRegion style. I'd like code to sort Sheet 2 based on the rows on Sheet 1. I spent a day trying to use Custom Sort dialog and failed. Now I've tried a double loop and can't get my i and j counters to do what I need.

    See the attached for the real problem.

    Thanks in advance... Here is the file:
    Sort by Groups Problem.xlsx

    I know how to rep.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Sort by Teams across

    Using CustomList.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Sort by Teams across

    Great Jindon. As for using this approach causes excel to be restarted on my side. I have tested the code and it worked very well. But when trying to save the workbook, excel hangs and when opening the file again, I found the data unsorted and the changes are unsaved.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Sort by Teams across

    Another way with the "i and j counters":
    Please Login or Register  to view this content.
    Last edited by millz; 01-05-2021 at 02:23 AM. Reason: combined "with" statements
    多么想要告诉你 我好喜欢你

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Sort by Teams across

    My first post requirs to save the file as 97-2003.
    This is for later version.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Sort by Teams across

    Another option...
    Please Login or Register  to view this content.
    Last edited by Sintek; 01-05-2021 at 04:10 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Sort by Teams across

    For MS365 Please try

    *** correction Need to add N(IF(1


    Please Login or Register  to view this content.
    or for dynamic range

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Bo_Ry; 01-05-2021 at 06:10 AM. Reason: Add N(IF(1

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,375

    Re: Sort by Teams across

    Hi Yasser,

    While trying Jindon's type of answer above, my code kept closing Excel without any prompt. Excel would simply "go away"!! I'm glad you saw this behavior also. I think there must be problem in Excel in the Application.AddCustomList or perhaps the Application.DeleteCustomList Application.CustomListCount .

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,375

    Re: Sort by Teams across

    Hi millz,

    You did what I attempted and see I was missing your s counter. I like your answer but why doesn't the range redraw with each change instead of all at the end with the .resize? It almost looks like an Application.DisplayAlerts on and off. ??

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,375

    Re: Sort by Teams across

    Hi sintek,

    You answer didn't work for me. It looks like you were trying to set a custom sort list and use it... Jindon's method did work for this.

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,375

    Re: Sort by Teams across

    Hey Bo_Ry,

    Both your answers worked. I can't believe you did the problem in a single line of code in the first answer. After spending a few hours trying to understand Evaluate, Replace, SortBy, Sequence and the N() function, I gave up and bow to both your solutions. I guess I need to study a lot more... Is N() the Null to Zero from Access? I've never seen it used in Excel. Can you point me to your sources to explain what your code does?

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Sort by Teams across

    Quote Originally Posted by MarvinP View Post
    Hi sintek,

    You answer didn't work for me. It looks like you were trying to set a custom sort list and use it... Jindon's method did work for this.
    Apologies Marvin...Simplified code without testing...

    Missed criteria setting...
    Please Login or Register  to view this content.
    Have uploaded with result after code runs...
    Attached Files Attached Files
    Last edited by Sintek; 01-05-2021 at 02:53 PM.

  13. #13
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Sort by Teams across

    Thanks for the rep

    Shorten code

    Please Login or Register  to view this content.
    I'm a formula guy so the whole code is base on this MS365 formula.

    =SORTBY(A2:O44,MATCH(A2:A44,FILTERXML("<x><m>"&TEXTJOIN("</m><m>",,Sheet1!F7:I17)&"</m></x>","//m"),))


    This is for flatten array Player 1-4 into 1 columns
    =FILTERXML("<x><m>"&TEXTJOIN("</m><m>",,F7:I17)&"</m></x>","//m")

    MATCH(A2:A44,FILTERXML()) to find sequece for sort A2:O44

    You may check Excelisfun video for dynamic array
    https://www.youtube.com/watch?v=Vj6yIIvK7p4


    I have a clip for FilterXML but it in Thai
    https://youtu.be/0mxhftN4Fk4


    Sortby is working the same way as this code

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Bo_Ry; 01-06-2021 at 03:31 AM.

  14. #14
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Sort by Teams across

    Quote Originally Posted by MarvinP View Post
    but why doesn't the range redraw with each change instead of all at the end with the .resize? It almost looks like an Application.DisplayAlerts on and off. ??
    Hi Marvin, not sure if I understood your question correctly, but I'll try to explain in detail, in case anyone else needs a similar sorting algorithm.

    Please Login or Register  to view this content.
    There were no moving of cells, nor copy/paste/insert/delete, so the formatting of the entire range remains the same. Everything was done within the array "a"

+ 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 and create golf teams from handicap
    By jndipworm in forum Excel General
    Replies: 15
    Last Post: 04-06-2023, 07:54 AM
  2. Replies: 7
    Last Post: 03-23-2022, 06:53 PM
  3. Sort bowlers into teams by average
    By pguarino in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-07-2019, 03:12 PM
  4. [SOLVED] Rating football teams/calculating superiority of football teams
    By gko_87 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-09-2017, 04:01 PM
  5. [SOLVED] Two columns of teams, count the number of times the teams meet?
    By tpe102 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-04-2013, 09:21 AM
  6. Macro to sort bowlers into teams by average
    By pguarino in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-18-2012, 12:25 AM
  7. Sort and Rank teams Win Loss Draw Tally in round robin tournament
    By jammjamm in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-07-2012, 06:19 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