+ Reply to Thread
Results 1 to 6 of 6

Combining multiple line items into one line item based on column.

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    Washington
    MS-Off Ver
    Excel 2003
    Posts
    1

    Combining multiple line items into one line item based on column.

    Hey guys,

    Any idea how I can solve this issue? Attached is an example file of what I'm trying to accomplish..

    The tab labeled "TestEx." has all the raw information. The "DesiredNeed" tab is what I would like it to look like after running a macro.

    Example: I want to consolidate all line items that have the same "ID" into one line item that also has the sum of the "Cost" column.

    Your help is greatly appreciated!
    Attached Files Attached Files

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

    Re: Combining multiple line items into one line item based on column.

    Try the attached
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Combining multiple line items into one line item based on column.

    mguz018,

    Welcome to the Excel Forum.


    Detach/open workbook ConsolidateID - w1 ADVFU colA wR colA - VLOOKUP SUMIF - mguz018 - EF851473 - SDG10.xls and run the ConsolidateID macro.


    If you want to use the macro on another workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the ConsolidateID macro.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining multiple line items into one line item based on column.

    A Pivot Table is the way to go here. You can find Pivot Table on your Data > Pivot Table menu.

    Here's a video showing me creating a pivot table from your data.


    http://screencast.com/t/OnHnSGAz
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    08-01-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Combining multiple line items into one line item based on column.

    I need help adding one extra step to this code. In column (I), if the ID contains two unique items is there a way to list them with a comma between them. Also, instead of putting a "0" in each blank row can you just copy the cell refernce from the orignal tab? Thanks for your help

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Combining multiple line items into one line item based on column.

    Hello dirock, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ 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