Link to home
Start Free TrialLog in
Avatar of Tim
TimFlag for Canada

asked on

How to transfer muti columns values to just 2 columns values in excel.

I have a excel file , table value like below
A1, B1, B2, B3, ......, BN
A2, C1, C2, C3,........,CN
......
AN, N1, N2, N3,...., NN

need transfer like just two columns excel file:
A1, B1
A1, B2
A1, B3
.....
A1, BN
A2, C1
A2, C2
A2, C3
....
A2, CN
......

Who can help me deal with this, thanks
Avatar of Norie
Norie

Which version of Excel do you have?

If it's a later version then you could easily do this using Power Query/Get and Transform, otherwise you would probably be best with code.

PS I'm assuming A1, B1, C1 etc are all in separate cells.
Avatar of Tim

ASKER

Yes , A1, B1 , C1 are all in separate cell value.
I am using excel 2013, I do not know the Power Query or ..
Anyone can help me do this code?

Thanks
I think if you are using 2013 you would need to install Power Query as an add-in, it's built-in in recent versions.

Anyway, If you could attach a sample workbook with some data I'll post some code.

PS I can do it without the sample workbook but seeing some 'real' date would be handy.:)

PPS It doesn't actually need to be 'real' data, just a mockup of what you are actually dealing with.
Avatar of Tim

ASKER

Hi Norie:
Thank you very much. I upload the sampledata, the regular is very big.
I would like transfer sheet1 to sheet2.

Thank you again
sampledata.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tim

ASKER

Hi Norie:

Thank you very much. It is work for me.
Tim,  

If you get a chance to learn Power Query on your own, may I suggest you try "M is for Data Monkey" by Ken Puls - it's is a very good place to start.  I have no financial interest with Mr. Puls - this is just a personal recommendation.  The amazing thing is after a light week with Ken's book (almost fun to read), you'll know how to solve problems like this in 5 minutes or less.  There are other books on Power Query, that tackle Data mash-up problems more broadly and deeply.  
Here, the thing to know is that Power Query User Interface has a button for "Un-pivot" data; the result automatically generates M language shown below.  If you plug this in Advance Query Editor, you'll get your expected result.  

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Column1"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"})
in
    #"Removed Columns"

Open in new window

Avatar of Tim

ASKER

Hi Dan:
Thank you very much. I will check Power Query.