Merge Rows of serial numbers if Item Number is the same

benchris

New Member
Joined
Feb 10, 2016
Messages
24
Office Version
  1. 2019
Platform
  1. Windows
I have a scenario I am not sure how to accomplish what I need to accomplish. I have Item numbers in column A and serial numbers for that item number in Columns B-E. Column A will have duplicate values, which I would like to have them all in the same row. For if Item 1 is in A1, A7, A12, A17 and A22, then all of the serial numbers for those rows would need to go to Cells Behind A. So in essence I would like to merge the data that each item number has into one row as shown. Any ideas on how to accomplish this? So you can see all of the serial numbers for Item 1 would go into the same row. After the forumula is run, preferably in a new sheet there would be 5 rows for each item and then all of those serial numbers for that item behind. I would then transpose the rows into columns when I am done as I need the items in columns rather than rows. Let me know if you have any ideas on how I can accomplish this.
Item NumberSerialSerialSerialSerial
Item 1
1​
22​
43​
64​
6​
27​
48​
69​
11​
32​
53​
74​
16​
37​
58​
79​
21​
42​
63​
84​
Item 2
2​
23​
44​
65​
Item 3
3​
24​
45​
66​
Item 4
4​
25​
46​
67​
Item 5
5​
26​
47​
68​
Item 1
6​
27​
48​
69​
Item 2
7​
28​
49​
70​
Item 3
8​
29​
50​
71​
Item 4
9​
30​
51​
72​
Item 5
10​
31​
52​
73​
Item 1
11​
32​
53​
74​
Item 2
12​
33​
54​
75​
Item 3
13​
34​
55​
76​
Item 4
14​
35​
56​
77​
Item 5
15​
36​
57​
78​
Item 1
16​
37​
58​
79​
Item 2
17​
38​
59​
80​
Item 3
18​
39​
60​
81​
Item 4
19​
40​
61​
82​
Item 5
20​
41​
62​
83​
Item 1
21​
42​
63​
84​
After everything is done I would like to have the table look like this with all of the serial numbers behind the item number:
Item NumberSerialSerialSerialSerial
Item 1
1​
22​
43​
64​
6​
27​
48​
69​
11​
32​
53​
74​
16​
37​
58​
79​
21​
42​
63​
84​
Item 2
2​
23​
44​
65​
7​
28​
49​
70​
12​
33​
54​
75​
17​
38​
59​
80​
Item 3
3​
24​
45​
66​
8​
29​
50​
71​
13​
34​
55​
76​
18​
39​
60​
81​
Item 4
4​
25​
46​
67​
9​
30​
51​
72​
14​
35​
56​
77​
19​
40​
61​
82​
Item 5
5​
26​
47​
68​
10​
31​
52​
73​
15​
36​
57​
78​
20​
41​
62​
83​
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Using Power Query...

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
1Item NumberSerial1Serial2Serial3Serial4Serial5Serial6Serial7Serial8Serial9Serial10Serial11Serial12Serial13Serial14Serial15Serial16Serial17Serial18Serial19Serial20
2Item 112243646274869113253741637587921426384
3Item 22234465
4Item 33244566
5Item 44254667
6Item 55264768
7Item 16274869
8Item 27284970
9Item 38295071
10Item 49305172
11Item 510315273
12Item 111325374
13Item 212335475
14Item 313345576
15Item 414355677
16Item 515365778
17Item 116375879
18Item 217385980
19Item 318396081
20Item 419406182
21Item 520416283
22
23
24Item NumberCount.1Count.2Count.3Count.4Count.5Count.6Count.7Count.8Count.9Count.10Count.11Count.12Count.13Count.14Count.15Count.16Count.17Count.18Count.19Count.20Count.21Count.22Count.23Count.24Count.25Count.26Count.27Count.28Count.29Count.30Count.31Count.32
25Item 11224364627486911325374163758792142638462748691132537416375879
26Item 2223446572849701233547517385980
27Item 3324456682950711334557618396081
28Item 4425466793051721435567719406182
29Item 55264768103152731536577820416283
Sheet7


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Item Number"}, {{"Count", each _, type table [Item Number=nullable text, Serial1=nullable text, Serial2=nullable text, Serial3=nullable text, Serial4=nullable text, Serial5=nullable text, Serial6=nullable text, Serial7=nullable text, Serial8=nullable text, Serial9=nullable text, Serial10=nullable text, Serial11=nullable text, Serial12=nullable text, Serial13=nullable text, Serial14=nullable text, Serial15=nullable text, Serial16=nullable text, Serial17=nullable text, Serial18=nullable text, Serial19=nullable text, Serial20=nullable text]}}),
    UP = Table.TransformColumns(Group,{{"Count", each Text.Combine(Table.UnpivotOtherColumns(_, {"Item Number"}, "Attribute", "Value")[Value],",")}}),
    Split = Table.SplitColumn(UP, "Count", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv))
in
    Split
 
Upvote 0
Thanks, I have never used Power Query but will get that figured out! Appreciate the response!
 
Upvote 0
If you have the Office 365 version of Excel you can do it with formulas like this.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
1Item
2Item 112243646274869113253741637587921426384
3Item 22234465
4Item 33244566
5Item 44254667
6Item 55264768
7Item 16274869
8Item 27284970
9Item 38295071
10Item 49305172
11Item 510315273
12Item 111325374
13Item 212335475
14Item 313345576
15Item 414355677
16Item 515365778
17Item 116375879
18Item 217385980
19Item 318396081
20Item 419406182
21Item 520416283
22
23Item 11224364627486911325374163758792142638462748691132537416375879
24Item 2223446572849701233547517385980
25Item 3324456682950711334557618396081
26Item 4425466793051721435567719406182
27Item 55264768103152731536577820416283
Sheet8
Cell Formulas
RangeFormula
A23:A27A23=UNIQUE(A2:A21)
B23:AG23,B24:Q27B23=TRANSPOSE(FILTERXML("<a><b>" & TEXTJOIN("</b><b>",1,IF(($A$2:$A$21=A23)*($B$2:$U$21<>""),$B$2:$U$21,""))&"</b></a>","//b"))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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