+ Reply to Thread
Results 1 to 8 of 8

How to match a column to another column?

  1. #1
    Registered User
    Join Date
    11-14-2017
    Location
    Saudi Arabia
    MS-Off Ver
    MS Office 2016
    Posts
    11

    How to match a column to another column?

    Hi,

    I want to match a set of database information by their ID column to another ID column with a different arrangement.

    rayat_bb_sort.png

    In the picture, I want to arrange ID2 to be like ID1.

  2. #2
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to match a column to another column?

    Hi,

    Welcome to the Forum.

    Can you post the sample file in excel format instead of image? Remember to delete any confidential info before the upload.

  3. #3
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: How to match a column to another column?

    Hello wolfrose,

    I worked something basic up based on the image in your example. The code would obviously need quite a lot of customization to its location in your worksheet, but hopefully it helps.

    Let me know if I can be of any further assistance,

    DarkF1ame

    Edit: I didn't create a button that makes use of the two macros...oversight on my part. The first moves the whole chunk of data other than id1 and then the second macro goes through and matches them up. I believe I wrote all of the "For" loops to be dynamic such that it will work no matter the length of data. All of the basepoints for ranges, column numbers, etc. would need to be customized by you.
    Attached Files Attached Files
    Last edited by DarkF1ame; 11-14-2017 at 11:56 AM.
    Mark as "Solved" and add Reputation if applicable.

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to match a column to another column?

    Based on your picture from post #1, I would first put two empty columns between the username and id1 columns since the rows do not belong together.

    You can then create a column to the right of the id1 column with 1, 2, 3, etc.

    Then, create a second helper column (this time to the right of the username column) using a lookup formula (such as VLOOKUP or INDEX MATCH) to match the id columns and return the number from the first helper column (that is 1, 2, 3, etc.).

    Then sort your data on the second helper column.

  5. #5
    Registered User
    Join Date
    11-14-2017
    Location
    Saudi Arabia
    MS-Off Ver
    MS Office 2016
    Posts
    11

    Re: How to match a column to another column?

    Here's a sample of the file.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-14-2017
    Location
    Saudi Arabia
    MS-Off Ver
    MS Office 2016
    Posts
    11

    Re: How to match a column to another column?

    Quote Originally Posted by DarkF1ame View Post
    Hello wolfrose,

    I worked something basic up based on the image in your example. The code would obviously need quite a lot of customization to its location in your worksheet, but hopefully it helps.

    Let me know if I can be of any further assistance,

    DarkF1ame

    Edit: I didn't create a button that makes use of the two macros...oversight on my part. The first moves the whole chunk of data other than id1 and then the second macro goes through and matches them up. I believe I wrote all of the "For" loops to be dynamic such that it will work no matter the length of data. All of the basepoints for ranges, column numbers, etc. would need to be customized by you.
    I'm sorry I didn't see any macros. I don't know much about advanced functions in excel, I try to do simple things, but I saw today a video on youtube about macros and it's very helpful to do certain orders.

  7. #7
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to match a column to another column?

    Post #4 will do this for you. Now that I see the actual worksheet, I can be more specific.

    Highlight column D > Home > Insert > Insert
    In G2 type 1 and in G3 type 2. Highlight G2:G3 and drag the numbers down column G (this should produce 1 through 33 in column G starting in G2).

    Now type "Helper Column" in D1 and then enter this formula in D2:
    =INDEX(G:G,MATCH(C2,F:F,0))
    Copy this formula down column D.

    Highlight columns A:D > Data > Sort by: Helper Column > OK

    Now you can delete your helper columns if you'd like.

  8. #8
    Registered User
    Join Date
    11-14-2017
    Location
    Saudi Arabia
    MS-Off Ver
    MS Office 2016
    Posts
    11

    Re: How to match a column to another column?

    Quote Originally Posted by 63falcondude View Post
    Based on your picture from post #1, I would first put two empty columns between the username and id1 columns since the rows do not belong together.

    You can then create a column to the right of the id1 column with 1, 2, 3, etc.

    Then, create a second helper column (this time to the right of the username column) using a lookup formula (such as VLOOKUP or INDEX MATCH) to match the id columns and return the number from the first helper column (that is 1, 2, 3, etc.).

    Then sort your data on the second helper column.
    That sounds like what I want, I would like you to help me on the uploaded file.

+ 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: 05-30-2015, 04:38 PM
  2. [SOLVED] Compare 1 column with another column and match data in next column
    By screambeam in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2015, 02:49 AM
  3. [SOLVED] Dynamic search; using column # result to determine column used for column/row match.
    By David Brunk in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-18-2014, 09:57 PM
  4. Copy data from column K to column B if Column C and column I match
    By goog2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2013, 12:19 PM
  5. Replies: 4
    Last Post: 10-07-2012, 06:56 AM
  6. [SOLVED] Match dates in column B with column A across worksheets and sum any amounts in column G
    By daddywine in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-04-2012, 01:07 AM
  7. Replies: 4
    Last Post: 12-14-2009, 03:21 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