+ Reply to Thread
Results 1 to 8 of 8

Transpose based on key

  1. #1
    Registered User
    Join Date
    07-08-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    1

    Transpose based on key

    Hi,

    Trying to organise a spreadsheet so all the items with the same key are in the same row. Currently its all in just 2 columns like below:


    Key Part No
    1 F124
    1 FR124
    1 FLW124
    1 FS124
    2 F2941
    2 DW2941


    Instead I want it to look like the below:

    1 F124 FR124 FLW124 FS124
    2 F294 DW2941

    Is there an easy way of applying this to large amounts of data?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Transpose based on key

    You get better result on your question if you add a small excel file, without confidential information.

    Please also add the expected results manualy in your file.

    What determines the key (is the the value 1.... then 2.... etc)?
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

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

    Re: Transpose based on key

    Input in Sheet1
    Output in Sheet2
    Assumes input table is only two columns


    Please Login or Register  to view this content.
    Last edited by Special-K; 07-08-2016 at 06:19 AM.
    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.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,019

    Re: Transpose based on key

    Try this VBA solution
    Please Login or Register  to view this content.

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Transpose based on key

    Here is a formula solution
    Enter formula in D2 and copy across until you see blanks and then down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B C D E F G
    1 Key Part No Key
    2 1 F124 1 F124 FR124 FLW124 FS124
    3 1 FR124 2 F2941 DW2941
    4 1 FLW124
    5 1 FS124
    6 2 F2941
    7 2 DW2941
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,852

    Re: Transpose based on key

    Assuming your data is in columns A and B, you can put this formula in C2:

    =IF(A2="","-",A2&"_"&COUNTIF(A$2:A2,A2))

    Copy this down as far as you like, to accommodate new data being added. The hyphens will show where the formula is active.

    List your individual keys in column E, starting with E2, then put this formula in F2:

    =IFERROR(INDEX($B:$B,MATCH($E2&"_"&COLUMNS($F:F),$C:$C,0)),"")

    Copy this across and down, as required.

    The attached file illustrates this.

    Hope this helps.

    Pete
    Attached Files Attached Files

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Transpose based on key

    Quote Originally Posted by MattPM View Post
    Is there an easy way of applying this to large amounts of data?
    How much is a "large amount of data"?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Registered User
    Join Date
    12-26-2013
    Location
    Sarawak, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Transpose based on key

    Try this, assumes that Row 1 is header row and data starts in cell A2
    Please Login or Register  to view this content.
    This will work fast for large data sets (even if in excess of 1,000,000 rows of data)
    Last edited by crj54; 07-08-2016 at 09:17 AM.

+ 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] Transpose Row to Column based on Date
    By neo4ride in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-07-2015, 09:25 AM
  2. Transpose variable based on 2 conditions
    By jam320 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-13-2015, 11:00 AM
  3. Transpose data based on value
    By JimmyG. in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-06-2015, 05:26 PM
  4. [SOLVED] Paste and transpose based Header
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2014, 09:03 AM
  5. transpose based on criteria
    By SHIGO in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-09-2012, 10:21 PM
  6. transpose based on criteria
    By SHIGO in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2012, 08:48 PM
  7. Excel 2007 : Transpose records based on date
    By aldek in forum Excel General
    Replies: 5
    Last Post: 11-03-2011, 12:35 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