Home > database >  Excel : Copy muitple columns to rows based on one column
Excel : Copy muitple columns to rows based on one column

Time:03-08

I'm looking for the most efficient approach to transferring information from three columns to one row, right next to each other depending on the company name. Consider the following example:

  1. I have a 226k data list with product details for several customers (around 30-40k).
  2. One customer can have 2 to 50 products, each with a serial number and a product number. Check out the source data pic.

Output required: One row per customer will have all the product data, serial number, and product number next to each other.

Source data

Source data

desired output desired output

I have never used Macro. Can someone please help me find the best way to deal with this issue?

CodePudding user response:

This one is pretty tricky, you'll need to play with column numbers to adjust formula:

enter image description here

The customer list in column F must be typed manually or if you have Excel 365 you may benefit from UNIQUE Function. I did it manually.

My formula in cell G2 is an array formula (must be entered pressing SHIFT CTRL ENTER or it won't work!

=IFERROR(INDEX(SI($D$2:$D$14=$F2;CHOOSE(COLUMN()-6-INTEGER((COLUMN()-7)/3)*3;$A$2:$A$14;$B$2:$B$14;$C$2:$C$14);"");MATCH($F2;$D$2:$D$14;0) INTEGER((COLUMN()-7)/3));"")

Drag to right and then drag to down.

My formula uses the value 6 and 7 because my data starts at column G, that means column number 7. So if you put this somewhere else, make sure you change also 7 and 6 values to the proper values!

Anyways, I've uploaded a sample to Gdrive in case you want to check the formulas by yourself.

https://docs.google.com/spreadsheets/d/1TvNUVt0ArzyFK_jsRtZfX1ja2zUgSdhR/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true

  • Related