+ Reply to Thread
Results 1 to 9 of 9

macro to combine multiple columns based on ID

  1. #1
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    macro to combine multiple columns based on ID

    OK, I have some very large worksheets and a macro would save me days in this situation.

    The raw data outputs a sheet with various columns, column A being the ID field. This is not a unique field and contains duplicates.

    For each unique ID, i would like to combine all of the data that is unique to that ID per column.

    For example, on the attached sheet the first ID is 1. Going across the columns, column B has 1 set of unique data for 1 ("A"), column C has 1 set ("B"), column D has 1 set ("C"), column E has 2 unique records ("D" for first 1, "E" for second 1), and column F has two unique records ("111" for first and "112" for second). I would like one row outputed on a differrent sheet:
    (sep columns)
    "1" "A" "B" "C" "D/E" "111/112"

    Is this a feasible request or too difficult? I am currently doing this manually and is taking hours as the sheets are 30K rows each :/
    Attached Files Attached Files
    Last edited by TechRetard; 02-02-2011 at 06:17 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: macro to combine multiple columns based on ID

    Try this macro
    Please Login or Register  to view this content.
    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007.
    Last edited by mrice; 02-02-2011 at 04:28 PM.
    Martin

  3. #3
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    Re: macro to combine multiple columns based on ID

    Wow impressive...albiet slow (20min to get through the first page) it works!

    Any tricks to speed up this macro? screenupdating=false?

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: macro to combine multiple columns based on ID

    Screenupdating = False is worth a try

    You might also try

    Please Login or Register  to view this content.
    with a manual filter/delete at the end.

  5. #5
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    Re: macro to combine multiple columns based on ID

    That isn't working -- it just scrolls "deleteme" across row 1
    Last edited by TechRetard; 02-02-2011 at 05:49 PM. Reason: i type like a 2 year old

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: macro to combine multiple columns based on ID

    Sorry - typo

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    Re: macro to combine multiple columns based on ID

    Niceee...that just did 30K lines in 4 min....that will work. Thank you sir

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: macro to combine multiple columns based on ID

    see attachment, run macro "test", i think that will be quicker
    Attached Files Attached Files
    Last edited by watersev; 02-02-2011 at 06:31 PM. Reason: oops i'm a bit late :)

  9. #9
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    Re: macro to combine multiple columns based on ID

    Hello Mr. Mrice ... May you please take a look at this thread

    http://www.excelforum.com/excel-prog...fic-cells.html

    it's about something like this post here but with a little different , hope you can help since i don't know about the VBA codes.

    Thank you in advance

+ 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