+ Reply to Thread
Results 1 to 16 of 16

Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    17

    Question Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Hi

    I have a 2-column spreadsheet, where the values in column 1 repeat but the values in column 2 are unique.

    Column 1 Column 2
    ADD Joe
    ADD Pete
    ADD Harry
    ADD Tom
    ADD Jenny
    BEN Joe
    BEN Pete
    BEN Tom
    BEN Jenny
    CAD Joe
    CAD Pete
    CAD Tom
    CAD Harry

    I want to flip it so Column 1 becomes the Column headings for as many as needed (no repeats) and then the values of COlumn 2 fall in line where necessary.

    ADD BEN CAD
    Joe Joe Joe
    Pete Pete Pete
    Harry Harry
    Tom Tom Tom
    Jenny Jenny


    I tried PIVOT TABLES, but only get this:

    ADD BEN CAD
    Joe
    Pete
    Harry
    Tom
    Jenny

    (no matter how many times I edit this post, this last table doesn't appear correctly. The names are showing up as column 1 and ADD, BEN and CAD are showing as the headers for Columns 2 through 4. I hope this makes sense.)

    The TRANSPOSE function didn't work either.

    There are over 3,700 rows for this spreadsheet and can't even imagine attempting this manually! :-(

    I'd really appreciate any help on this.

    Thanks!
    Jim
    Last edited by jdegeorge; 09-12-2012 at 02:17 PM. Reason: Example tables didn't display correctly.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Try

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-12-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    JieJenn

    Thanks for the quick response, but I haven't a clue what to do with your code. Basically, if Excel doesn't have a built-in function button I'm at a loss.

    Jim

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    A formula approach
    Step 1: Copy Col A to E1, Copy Col B to F2
    Step 2: Data tab> Remove Duplicates on E and then on F
    Copy Unique values from E to G1:?1 using Paste Special > transpose
    Step 3: In G2, dragged across and down, =IF(COUNTIFS($A$1:$A$13,G$1,$B$1:$B$13,$F2)>0,$F2,"")
    Step 4: Copy, Paste Special Values over new table to remove formulas
    See attachment
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Nice code approach Jie

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Oh my bad. Hit Alt + F11 to open the VBA window, on the menu on top, click on insert > module. Then just copy and paste the code and hit F5 (or click on Macro and select the procedure and hit run) to run the macro.

  7. #7
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Quote Originally Posted by ChemistB View Post
    Nice code approach Jie
    More like I am too lazy to come up with a formula

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    I spoke too soon. I get the following when I run your code
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Somethings amiss.

  9. #9
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Good catch. Just came back from lunch. Here try the revised code

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-12-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Thanks, but your attached file puts each person in each column D through F, when that's not what's represented in columns A and B.

  11. #11
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Maybe I misunderstand your question. Can you upload a sample file with what the final result should look like.

  12. #12
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Give this a try

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  13. #13
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Nope, Harry shouldn't appear under BEN, and Jenny shouldn't appear under CAD. Unless my formulas are wrong

  14. #14
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Heres as sample workbook

    Transpose.xlsm

  15. #15
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    @JieJenn

    Heres an update to your code that should work

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    09-12-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Convert 2-Column Spreadsheet to Multi-Columns based on 1 Column

    Quote Originally Posted by ChemistB View Post
    A formula approach
    Step 1: Copy Col A to E1, Copy Col B to F2
    Step 2: Data tab> Remove Duplicates on E and then on F
    Copy Unique values from E to G1:?1 using Paste Special > transpose
    Step 3: In G2, dragged across and down, =IF(COUNTIFS($A$1:$A$13,G$1,$B$1:$B$13,$F2)>0,$F2,"")
    Step 4: Copy, Paste Special Values over new table to remove formulas
    See attachment

    I appreciate everyone's help, but I ran with ChemistB's solution because it looked more familiar. And...it worked! Thanks a bunch!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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