Avatar of Tim
Tim
Flag 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
Microsoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Tim

8/22/2022 - Mon
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.
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
Norie

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
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
Norie

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Tim

ASKER
Hi Norie:

Thank you very much. It is work for me.
Dan

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

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Tim

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