+ Reply to Thread
Results 1 to 17 of 17

Combine rows with same column value into one row with several columns for that value

  1. #1
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Combine rows with same column value into one row with several columns for that value

    Hi,

    I was wondering if anyone knows how to combine rows (in Excel 2013) with the same value (in one column) into one row with several columns for that value and its columns?

    I've attached a picture of what I am looking for:

    excel combine rows.png

    I made a VBA Macro several months ago that I believe worked well, but unfortunately I didn't test it more than once and now I cannot find the code.

    What's the best solution to this "issue"?

    Thanks in advance,

    Best regards,

    Ps, I've also asked this in Stackoverflow but thought I'll give it a try here as well, since I haven't figured it out yet.

  2. #2
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Combine rows with same column value into one row with several columns for that value

    You could use VLOOKUP with a couple of helper columns
    Attached Files Attached Files

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Combine rows with same column value into one row with several columns for that value

    Ps, I've also asked this in Stackoverflow but thought I'll give it a try here as well, since I haven't figured it out yet.
    Provide the forum link in accordance with our forum rules.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    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

  4. #4
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Re: Combine rows with same column value into one row with several columns for that value

    Hi, thanks for your replies, sorry that I forgot to include the other link, I couldn't post any links until I posted a few times though?

    How would I approach to do it with Vlookup? I would very much appreciate if you would like to explain, as I am trying to learn more and more about Excel every day

    Thanks in advance,

    Best regards,

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Combine rows with same column value into one row with several columns for that value

    In an effort to avoid spammers form posting, you need to have 10 posts to copy and paste a link. Please however, type out the address of your other post in accordance with the rules of this forum.

  6. #6
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Combine rows with same column value into one row with several columns for that value

    Once you provide the link, also provide the example workbook so we can help. See yellow banner above.

  7. #7
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Combine rows with same column value into one row with several columns for that value

    Quote Originally Posted by Jonthee View Post
    Hi, thanks for your replies, sorry that I forgot to include the other link, I couldn't post any links until I posted a few times though?

    How would I approach to do it with Vlookup? I would very much appreciate if you would like to explain, as I am trying to learn more and more about Excel every day

    Thanks in advance,

    Best regards,
    So my example was no help?

  8. #8
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Re: Combine rows with same column value into one row with several columns for that value

    alansidman:

    Hi,

    I no longer have any posts on other websites, I formulated the question in an unclear way so I deleted it all, thinking this is the best place to ask this

    Best regards,
    Last edited by Jonthee; 06-21-2020 at 04:11 AM.

  9. #9
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Re: Combine rows with same column value into one row with several columns for that value

    maniacb: Thanks, I've attached the sample workbook here

    Croweater: I saw your example now, MANY THANKS, will it work out even with, lets say, 7 duplicated "part numbers", 4 duplicated, and so on?

    Thanks again for the help, really appreciate it.

    Have a great day,

    Best regards,
    Attached Files Attached Files

  10. #10
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Combine rows with same column value into one row with several columns for that value

    Hi Jonthee … Try the below code

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  11. #11
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Re: Combine rows with same column value into one row with several columns for that value

    Hi, Thank you very much, unfortunately I cannot get it to work

    If I only have the A and B columns like my sample code, where and how do I put the macro VBA code to get the results in the D, E, F etc. columns, like the sample?

    I got some error with this line: Range("D2").Resize(.Count, 2) = Application.Transpose(Array(.keys, .items))

    Many thanks,

    Have a great day,

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Combine rows with same column value into one row with several columns for that value

    Try
    Please Login or Register  to view this content.
    Last edited by jindon; 06-22-2020 at 08:43 AM.

  13. #13
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Re: Combine rows with same column value into one row with several columns for that value

    Error code 9, index is outside interval: ReDim Preserve a(2 To UBound(a, 1), 1 To UBound(a, 2) + 100)

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Combine rows with same column value into one row with several columns for that value

    OOps, typo, 2 should be 1
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    06-19-2020
    Location
    Europe
    MS-Off Ver
    Office 2013
    Posts
    7

    Re: Combine rows with same column value into one row with several columns for that value

    Success, it works like a charm Many, many thanks, now I will try to understand everything

    Ps, just out of curiousity, is it possible to do it any other way? Not that need to now that this works so great, but I was just thinking Pivot Table, formula etc.?

    Best regards and thanks again,

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Combine rows with same column value into one row with several columns for that value

    No idea about PT,

    formula Assuming all the unique value in col.A listed in D2 onwards.
    E2
    =IFERROR(INDEX($A$2:$B$11,SMALL(IF($A$2:$A$11=$D2,ROW($A$2:$A$11)),COLUMN(A1)),2),"")
    Confirm with Ctrl + Shift + Enter(Array formula entry)
    Copy left + down

  17. #17
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Combine rows with same column value into one row with several columns for that value

    Quote Originally Posted by Jonthee View Post
    I got some error with this line: Range("D2").Resize(.Count, 2) = Application.Transpose(Array(.keys, .items))
    I know jindon has already provided a working code for you but I would like to know what is the error message that you got to understand what caused it as it works fine in my laptop ...

+ 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: 6
    Last Post: 08-02-2019, 02:38 AM
  2. [SOLVED] Combine multiple First/Last Name columns into one column, data can contain blank rows
    By Tunesmith in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-04-2016, 09:42 AM
  3. Replies: 6
    Last Post: 11-25-2015, 01:01 PM
  4. Combine Data in Multiple Columns to One Column Based on Data in Rows
    By exceldivx in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-09-2014, 07:35 AM
  5. MAcro to - copy, transpose, text to columns, remove column A, combine all columns in 1
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-07-2013, 08:48 AM
  6. Replies: 0
    Last Post: 07-31-2006, 12:13 PM
  7. Replies: 6
    Last Post: 05-03-2006, 04:30 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