+ Reply to Thread
Results 1 to 6 of 6

Consolidate data in multiple columns

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    194

    Consolidate data in multiple columns

    We get a work order export file daily that is usually about 40K lines. The problem is that it is by work order (primary key if this were access) and it has multiple parts required on the same line. I need to consolidate the parts required columns into one while retaining the work order number, customer, and city. I've attached a screen shot of the sample data workbook. Using Excel 2013. Thanks for looking.

    Capture.JPG
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Lightbulb Re: Consolidate data in multiple columns

    Hi Mr Phil

    Try this
    Please Login or Register  to view this content.
    Cordialy
    Attached Files Attached Files
    If you are satisfied with my answer, please add reputation

  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,897

    Re: Consolidate data in multiple columns

    Using Power Query it is a simple case of unpivotting the data. Here is the Mcode to achieve that and the file is attached for your review. No coding required. All achieved in the UI.

    Please Login or Register  to view this content.
    Review PQ
    In the attached file
    Click on any cell in the new table
    On the Data Tab, click on Queries & Connections
    In the right window, double click to open Query
    Review PQ steps
    Attached Files Attached Files
    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
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this demonstration !


    According to the attachment another VBA beginner starter just using a single loop, result in sheet #2 :

    PHP Code: 
    Sub Demo1()
        
    Dim L&, R&, C%
            
    2
            Application
    .ScreenUpdating False
            
    If Worksheets.Count 1 Then Sheets.Add Sheets(1) Else Sheets(2).UsedRange.Clear
        With Sheets
    (1).[A1].CurrentRegion
               
    .Range("A1:C1").Copy Sheets(2).[A1]
            For 
    2 To .Rows.Count
                C 
    = .Cells(R1).End(xlToRight).Column 3
               
    .Cells(R1).Resize(, - (1)).Copy Sheets(2).Cells(L1).Resize(C)
                If 
    1 Then Sheets(2).Cells(L4).Resize(C) = Application.Transpose(.Cells(R4).Resize(, C))
                
    C
            Next
        End With
        With Sheets
    (2).UsedRange.Columns
            
    .NumberFormat "_wGeneral_w;;;_w@_w"
            
    .Cells(4) = "PART NEEDED"
            
    .AutoFit
            
    .Sort .Item(3), xlAscending, .Item(2), , xlAscending, , , xlYes
        End With
            Application
    .ScreenUpdating True
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » ! ◄ ◄
    Last edited by Marc L; 05-14-2020 at 07:41 PM.

  5. #5
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    194

    Re: Consolidate data in multiple columns

    I think this is really interesting. I’m going to have to study on it. I’ve never used power query. But it looks intriguing. Is it an add in?

    Quote Originally Posted by alansidman View Post
    Using Power Query it is a simple case of unpivotting the data. Here is the Mcode to achieve that and the file is attached for your review. No coding required. All achieved in the UI.

    Please Login or Register  to view this content.
    Review PQ
    In the attached file
    Click on any cell in the new table
    On the Data Tab, click on Queries & Connections
    In the right window, double click to open Query
    Review PQ steps
    Last edited by Mr_Phil; 05-14-2020 at 09:46 PM. Reason: Forgot to quote

  6. #6
    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,897

    Re: Consolidate data in multiple columns

    https://www.youtube.com/watch?v=gwW2CDdvUUs

    Also, look at the link in my signature block. It is a very cool and powerful feature of Excel. A good primer is "M is for (Data) Monkey" by Ken Puls and Miguel Escobar.

+ 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. Consolidate set of multiple columns to one set of columns to a new sheet
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2018, 09:59 AM
  2. Consolidate columns from multiple worksheets.
    By PaulAllen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-22-2017, 12:13 AM
  3. [SOLVED] Consolidate Multiple Columns into Single Column
    By AllanTheCowboy in forum Excel General
    Replies: 17
    Last Post: 08-02-2015, 06:30 PM
  4. Formula to consolidate hours (multiple columns of criteria)
    By egordon in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-13-2015, 04:30 PM
  5. Consolidate Data In Multiple Rows and Columns Into One Row
    By KiwDaWabbit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-09-2015, 03:06 PM
  6. Consolidate multiple columns and rows into one Column
    By jewels3059 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2013, 11:12 AM
  7. Replies: 3
    Last Post: 03-12-2013, 02:34 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