+ Reply to Thread
Results 1 to 11 of 11

Sort two colums so that equal cells are right next to each other

  1. #1
    Registered User
    Join Date
    08-23-2018
    Location
    Germany
    MS-Off Ver
    365
    Posts
    32

    Sort two colums so that equal cells are right next to each other

    Hi all,

    so I have a small excel problem that would save me a lot of time if I could solve it.
    I have two colums A and B each with random strings inside.
    What I want is that the cells with the same input (so the same random string) are sorted right next to each other.


    So colums A and B in the "Before Worksheet" are what I got, and the same colums in the "After Worksheet" are what I want to get. Is this possible in an easy manner?



    Thx for your help
    Attached Files Attached Files
    Last edited by MrMoody; 08-23-2018 at 04:16 AM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Sort two colums so that equal cells are right next to each other

    Good morning MrMoody

    Welcome to the forum!!

    Would you post your .pdf file as an Excel file. It is difficult to formulate a solution from static data that we cannot interact with.

    DominicB



    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitise the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    08-23-2018
    Location
    Germany
    MS-Off Ver
    365
    Posts
    32

    Re: Sort two colums so that equal cells are right next to each other

    Thank you for your answer. I just updated the file Thank you in advance

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Sort two colums so that equal cells are right next to each other

    in Before!C2
    =IFERROR(VLOOKUP(A2,B$2:B$23,1,0),"")
    and copy down the column as far as C23
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  5. #5
    Registered User
    Join Date
    08-23-2018
    Location
    Germany
    MS-Off Ver
    365
    Posts
    32

    Re: Sort two colums so that equal cells are right next to each other

    Thank you for your quick answer . Could u incorperate it into the provided excel file? I am not quite sure how to do it.
    Thank you very much

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Sort two colums so that equal cells are right next to each other

    Hi MrMoody

    The methodology of the attached does what you require, but it doesn't follow the methodology of what you have described in your post.

    Column J is a copy of what you have in column A.
    Column C compares each row in column A with the whole of column B to see if the value in A appears anywhere in B (ie is it a duplicate). The digit is the number of times A's value appears in B.
    Column K asks whether the value in J is marked as a duplicate, if so, show the value again, otherwise show blank.

    It's a bit off the wall, but it seems to work.

    HTH

    DominicB
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Sort two colums so that equal cells are right next to each other

    Quote Originally Posted by MrMoody View Post
    Thank you for your quick answer . Could u incorperate it into the provided excel file? I am not quite sure how to do it.
    Thank you very much
    Just type the formula as stated into C2 as you would any data.
    Ctrl-C to copy the formula.
    Select the cells C3:C23
    Ctrl-V to paste the formula.

  8. #8
    Registered User
    Join Date
    08-23-2018
    Location
    Germany
    MS-Off Ver
    365
    Posts
    32

    Re: Sort two colums so that equal cells are right next to each other

    Thank you all for your great help. Sorry it took me so long to come back to you yet I was on hollidays

    So your method worked fantasticly dominicb, thank you for that.

    Yet I have a second problem.

    So as before I have my sample set 1 in colum A and my sample set 2 in colum B. With your Method I managed to align the cells beeing the same seen in colum G and H.
    Yet I also have an order asigned to sample set 2, seen in colum C and I need these Numbers right next to their original string in colum B.

    You can see the intended result in the "After" Worksheet.

    Do you now how to achieve that as well?

    Thank you again for your help
    Attached Files Attached Files

  9. #9
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Sort two colums so that equal cells are right next to each other

    Good morning MrMoody

    If I follow you correctly, then something like this should work - copy the formula into cell I2, then copy down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    HTH

    DominicB

  10. #10
    Registered User
    Join Date
    08-23-2018
    Location
    Germany
    MS-Off Ver
    365
    Posts
    32

    Re: Sort two colums so that equal cells are right next to each other

    Awesome it works Thank you guys for all your help
    Last edited by MrMoody; 09-11-2018 at 04:50 AM.

  11. #11
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Sort two colums so that equal cells are right next to each other

    I see you are from Germany, if you use a German Excel than the formula =
    PHP Code: 
    =WENNFEHLER(SVERWEIS(H2;$A$2:$C$49;3;0);""
    Click the * Add Reputation below to say thanks.

+ 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. sort three colums
    By weenorm in forum Excel General
    Replies: 1
    Last Post: 03-02-2013, 04:24 AM
  2. Combining rows if data in certain colums are equal
    By cordeparker in forum Excel General
    Replies: 11
    Last Post: 07-09-2012, 08:16 PM
  3. Macro to sort colums and protect after sort
    By SilverFox in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-05-2009, 07:12 AM
  4. Auto Sort by Two Colums
    By racer25 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2005, 10:03 AM
  5. sort colums
    By damiancutts in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2005, 07:05 PM
  6. [SOLVED] Sort rows by colums
    By spartanfans13 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 08-01-2005, 04:05 PM
  7. [SOLVED] Automatically Sort colums
    By tamato43 in forum Excel General
    Replies: 2
    Last Post: 03-20-2005, 05:06 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