Convert multiple cell rows into one unique row

jamiguel77

Active Member
Joined
Feb 14, 2006
Messages
378
Office Version
  1. 2016
  2. 2010
  3. 2007
Platform
  1. Windows
  2. Web
HI
I have this data, the idea is to detect on column A, which data is repeated, triplicated, quadrupled.... and generate 1 single row.
LCCH MD ejemplo bmw Pedimentos de importacion v1.xlsx
ABCD
1
2Invoice1Invoice SalesGUIDQty
35045A78599609AB33-46E3-493B-B397-136BFFFC200410
45089A3242E26D032C-870F-48D5-AEB9-EFD2797C04255
55089A3278A612ED53-5DF8-4EDB-AA76-B02615D630CC18
Hoja1


the expected result is:

LCCH MD ejemplo bmw Pedimentos de importacion v1.xlsx
EFG
1EXPECTED RESULT
2Invoice SalesGUIDQty
3A78599609AB33-46E3-493B-B397-136BFFFC200410
4A3242, A3278E26D032C-870F-48D5-AEB9-EFD2797C0425, A612ED53-5DF8-4EDB-AA76-B02615D630CC5,18
5
Hoja1


is possible with formula? or need VBA?

thanks
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this macro:

VBA Code:
Sub convert_into_row()
  Dim i As Long
  Dim f As Range
  
  For i = 3 To Range("A" & Rows.Count).End(3).Row
    Set f = Range("A2:A" & i - 1).Find(Range("A" & i).Value, , xlValues, xlWhole)
    If f Is Nothing Then
      Range("E" & i).Resize(1, 3).Value = Range("B" & i).Resize(1, 3).Value
    Else
      Range("E" & f.Row).Value = Range("E" & f.Row).Value & ", " & Range("B" & i).Value
      Range("F" & f.Row).Value = Range("F" & f.Row).Value & ", " & Range("C" & i).Value
      Range("G" & f.Row).Value = Range("G" & f.Row).Value & ", " & Range("D" & i).Value
    End If
  Next
End Sub
 
Upvote 0
A way using Power Query.

EXCEL
ABCDEFGH
1Invoice1Invoice SalesGUIDQtyInvoice SalesGUIDQty
25045A78599609AB33-46E3-493B-B397-136BFFFC200410A78599609AB33-46E3-493B-B397-136BFFFC200410
35089A3242E26D032C-870F-48D5-AEB9-EFD2797C04255A3242,A3278E26D032C-870F-48D5-AEB9-EFD2797C0425,A612ED53-5DF8-4EDB-AA76-B02615D630CC5,18
45089A3278A612ED53-5DF8-4EDB-AA76-B02615D630CC18
Sheet2


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Cols = List.Skip(Table.ColumnNames(Source),1),
    Group = Table.SelectColumns(Table.Group(Source, {"Invoice1"}, List.Transform(Cols, (col)=> {col, each Text.Combine(List.Transform(Table.Column(_,col),Text.From),",")})),Cols)
in
    Group
 
Upvote 0
Try this macro:

VBA Code:
Sub convert_into_row()
  Dim i As Long
  Dim f As Range
 
  For i = 3 To Range("A" & Rows.Count).End(3).Row
    Set f = Range("A2:A" & i - 1).Find(Range("A" & i).Value, , xlValues, xlWhole)
    If f Is Nothing Then
      Range("E" & i).Resize(1, 3).Value = Range("B" & i).Resize(1, 3).Value
    Else
      Range("E" & f.Row).Value = Range("E" & f.Row).Value & ", " & Range("B" & i).Value
      Range("F" & f.Row).Value = Range("F" & f.Row).Value & ", " & Range("C" & i).Value
      Range("G" & f.Row).Value = Range("G" & f.Row).Value & ", " & Range("D" & i).Value
    End If
  Next
End Sub
Sorry Work, if the data is duplicated N times, sample 100 times, the code work? thanks
 
Upvote 0
sample 100 times, the code work?
Of course

Here an example:

varios 09ene2024.xlsm
ABCDEFG
1EXPECTED RESULT
2Invoice1Invoice SalesGUIDQtyInvoice SalesGUIDQty
35045A7859a10A7859, A7859, A7859, A7859a, d, h, k10, 10, 10, 10
45089A3242b5A3242, A3278, A3242, A3242, A3242, A3278, A3242, A3242b, c, e, g, i, j, l, n5, 18, 5, 5, 5, 18, 5, 5
55089A3278c18
65045A7859d10
75089A3242e5
81515A7859f10A7859, A7859f, m10, 10
95089A3242g5
105045A7859h10
115089A3242i5
125089A3278j18
135045A7859k10
145089A3242l5
151515A7859m10
165089A3242n5
Hoja1
 
Upvote 0
An alternative is with Power Pivot.
check out this link on how to achieve with Power Pivot.


Book6
ABCDEFGHI
2Invoice1Invoice SalesGUIDQtyRow LabelsInvoiceSalesGUIDsTotal Quanties
35045A78599609AB33-46E3-493B-B397-136BFFFC2004105045A78599609AB33-46E3-493B-B397-136BFFFC200410
45089A3242E26D032C-870F-48D5-AEB9-EFD2797C042555089A3242, A3278E26D032C-870F-48D5-AEB9-EFD2797C0425, A612ED53-5DF8-4EDB-AA76-B02615D630CC5. 18
55089A3278A612ED53-5DF8-4EDB-AA76-B02615D630CC18
6
Sheet1
 
Upvote 0

Forum statistics

Threads
1,215,332
Messages
6,124,313
Members
449,152
Latest member
PressEscape

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top