+ Reply to Thread
Results 1 to 8 of 8

Sort two columns so that matching numbers line up in rows

  1. #1
    Registered User
    Join Date
    02-28-2024
    Location
    Indiana
    MS-Off Ver
    365
    Posts
    4

    Cool Sort two columns so that matching numbers line up in rows

    Hello,

    I'm new to the forum so please forgive any protocol or category violation that I may have committed. I am fairly handy with Excel and am generally good with doing web searches to find my solutions. However, this time I have one that I can't figure out. It is a sorting issue.

    I have three columns containing many numbers that are each sorted numerically. In some cases, numbers in the columns are unique and do not appear in the other two columns. In other cases, numbers may appear in two, or even all three of the other columns. I am able to visually identify these numbers by using "Conditional Formatting", "Highlight Cells Rules", and then "Duplicate Values..." This of course changes any cells with duplicate values to pink. Therefore, I am able to at least visually see which cells have unique numbers because they remain white.

    My issue is that I would like to have all three columns sorted numerically so that any numbers that match in two or more columns line up with each other in the same row. I want numbers that are unique line up to blank cells in the other columns.

    I have attached a simple example of what I am trying to accomplish to this post. In the "Before Custom Sort" columns, I show a basic example of the kind of data that I have. I did a "Duplicate Values..." to it so you can easily see the pink matching cells. In the "After Custom Sort" columns, I have manually arranged them to demonstrate my desired results. I believe this spreadsheet explains itself.

    Is there any way I can accomplish this? I will add here that I am not at all versed in VBS, so I am not able to any sort of scripting to solve my issue. I am hoping that there is a straightforward solution to my problem by using functions found in the Ribbon.

    Thank you for any assistance you can provide.

    -Patrick
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: Sort two columns so that matching numbers line up in rows

    Welcome to the forum.

    I am loathe to start looking at this as the sample data may have been over-simplified. Does the real data follow the same pattern of consecutive values? If not, then could you please share something more realistic?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    02-28-2024
    Location
    Indiana
    MS-Off Ver
    365
    Posts
    4

    Re: Sort two columns so that matching numbers line up in rows

    I have attached my real data. I hope this helps. Thank you for your assistance.

    -Patrick
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-28-2024
    Location
    Indiana
    MS-Off Ver
    365
    Posts
    4

    Re: Sort two columns so that matching numbers line up in rows

    I just realized that my comment in cell D4 is incorrect. It says "A while cell indicates a missing number". It should say "A white cell indicates a unique number". Sorry for the confusion.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,991

    Re: Sort two columns so that matching numbers line up in rows

    I didn't ask for your full dataset, but it is better to see real data. Could you cut it down to something manageable? Say 20-30 rows of data AND the expected results mocked up manually. Thanks.

  6. #6
    Registered User
    Join Date
    02-28-2024
    Location
    Indiana
    MS-Off Ver
    365
    Posts
    4

    Re: Sort two columns so that matching numbers line up in rows

    Give this a look. Thank you.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2403)
    Posts
    370

    Re: Sort two columns so that matching numbers line up in rows

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Would something like an XLOOKUP help?
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Sort two columns so that matching numbers line up in rows

    Array formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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: 07-11-2019, 12:05 AM
  2. Matching 2 columns and sorting so they line up.
    By X82 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-23-2015, 09:35 AM
  3. Replies: 2
    Last Post: 05-02-2015, 10:49 AM
  4. Need to sort by matching columns
    By kendrick.meiners in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2013, 07:46 PM
  5. [SOLVED] Last line of multiple text files matching first column numbers only
    By c_schoonraad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2012, 03:07 PM
  6. [SOLVED] Matching numbers in multiple columns and aligning them in the same rows
    By DANNY DUNPHY in forum Excel - New Users/Basics
    Replies: 15
    Last Post: 10-08-2012, 07:34 PM
  7. [SOLVED] How do I sort numbers in a table (ie. rows & columns)?
    By Twinkle17 in forum Excel General
    Replies: 2
    Last Post: 12-02-2005, 01:00 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