creating multiple rows of data based on values in columns

mzza

Board Regular
Joined
Nov 8, 2006
Messages
55
Hi all,


I have a spreadsheet which currently looks something like this:


Code:
ID | Code1 | Code2 | Code3 | etc...
AA | 11122 | 31243 | 54645 | 
BB | 12398 | 23242 |       |
CC | 76766 |       |       |


However, I need it to look as follows:


Code:
ID | Code
AA | 11122
AA | 31243
AA | 54645
BB | 12398
BB | 23242
CC | 76766


... and I'm stumped on how to achieve this. Can anyone help? There are 18 'Code x' columns and 109,000 rows of data fwiw.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi

Load the table into Power Query.
Select column "ID".
Right click. "Unpivot other columns".
Close and load the new table into Excel.
 
Upvote 0
if you do it correctly (post#2), you should get the result:

IDCode1Code2Code3IDCode
AA
11122​
31243​
54645​
AA
11122​
BB
12398​
23242​
AA
31243​
CC
76766​
AA
54645​
BB
12398​
BB
23242​
CC
76766​


update :)
Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UnPivot = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
    RC = Table.RemoveColumns(UnPivot,{"Attribute"}),
    Ren = Table.RenameColumns(RC,{{"Value", "Code"}})
in
    Ren[/SIZE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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