Consolidating data from columns to rows

Oliver Yasuna

I have a spreadsheet:

Company 1 | ID1
Company 1 | ID2
Company 1 | ID3
Company 2 | ID4
Company 2 | ID5
Company 2 | ID6
Company 3 | ID7
Company 3 | ID8
Company 3 | ID9

I need to combine each company into one row, with all their IDs into columns to the right. There can be a different number of IDs per company.

The final result would look like:

Company 1 | ID1 | ID2 | ID3
Company 2 | ID4 | ID5 | ID6
Company 3 | ID7 | ID8 | ID9

How could I accomplish this? Preferably with VBA.

robinCTS

This single formula solution assumes that each company has the same number of rows:

Worksheet Screenshot

Enter the following formula in D2 and ctrl-enter/copy-paste/fill-down&right into the rest of the table:

=""&INDEX($A:$B,ROW($D$2)+3*INT(ROW()-ROW($D$2))+MAX(0,COLUMN()-COLUMN($D$2)-1),2-(COLUMN()=COLUMN($D$2)))

Note that this formula will work for any (identical) number of rows for each company, and will correctly adjust if rows or columns are added/removed.

However, the formula will break if the table it is in is copied/cut and pasted elsewhere. The $D$2s need to be changed to match the new table location's top-left data cell in order to make it work correctly again.


If there is a variable number of rows for each company, the single formula required is:

=IFERROR(IF(COLUMN()=COLUMN($D$2),""&INDEX($A:$A,MATCH(D1,$A:$A,0)+COUNTIF($A:$A,D1)),INDEX(INDEX($B:$B,MATCH($D2,$A:$A,0)):INDEX($B:$B,MATCH($D2,$A:$A,0)+COUNTIF($A:$A,$D2)-1),COLUMN()-COLUMN($D$2))),"")

Worksheet Screenshot

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update SQL data, consolidating columns

From Dev

move data from rows to columns

From Dev

Pandas: consolidating columns in DataFrame

From Dev

Copying & Consolidating Data from on-prem SQL server to Azure blob

From Dev

Consolidating array data

From Dev

copy specific columns from rows with duplicate data

From Dev

SQL Results data from rows to columns

From Dev

Excel - copy Data from multiple columns and rows

From Dev

R transforming data from columns to rows by variable

From Dev

Aggregating data from a combination of selected rows and columns

From Dev

Consolidating duplicate rows in a large dataframe

From Dev

INSERT INTO after CONCAT data from different columns from different rows

From Dev

Consolidating columns based on field value in bash

From Dev

Consolidating multiple columns into one column in R

From Dev

Consolidating columns based on field value in bash

From Dev

consolidating multiple columns into one column pandas

From Dev

Removal of Duplicate Rows from Data table Based on Multiple columns

From Dev

Writing Columns of data versus Rows in Excel from XML with XSLT

From Dev

Deleting a specific rows and columns from a data-set using Matlab

From Dev

How to exclude rows/columns from numpy.ndarray data

From Dev

Remove "duplicated" rows from data frame (they differ in few columns)

From Dev

SQL or MSEXCEL transpose data from rows to columns NOT PIVOT nor TRANSFORM

From Dev

Remove NAs from data frame without deleting entire rows/columns

From Dev

Event data from rows to columns by ID in R, Reshape?

From Dev

Pandas Create Columns From Rows in Other Data Frame with Criteria

From Dev

Remove rows from a data frame that contain duplicate information across the columns

From Dev

R: aggregation (median) of data.frame rows from >2 columns

From Dev

Excel VBA code to transpose data from rows to columns

From Dev

How to move Excel 2010 data from rows into 2 columns only?

Related Related

  1. 1

    Update SQL data, consolidating columns

  2. 2

    move data from rows to columns

  3. 3

    Pandas: consolidating columns in DataFrame

  4. 4

    Copying & Consolidating Data from on-prem SQL server to Azure blob

  5. 5

    Consolidating array data

  6. 6

    copy specific columns from rows with duplicate data

  7. 7

    SQL Results data from rows to columns

  8. 8

    Excel - copy Data from multiple columns and rows

  9. 9

    R transforming data from columns to rows by variable

  10. 10

    Aggregating data from a combination of selected rows and columns

  11. 11

    Consolidating duplicate rows in a large dataframe

  12. 12

    INSERT INTO after CONCAT data from different columns from different rows

  13. 13

    Consolidating columns based on field value in bash

  14. 14

    Consolidating multiple columns into one column in R

  15. 15

    Consolidating columns based on field value in bash

  16. 16

    consolidating multiple columns into one column pandas

  17. 17

    Removal of Duplicate Rows from Data table Based on Multiple columns

  18. 18

    Writing Columns of data versus Rows in Excel from XML with XSLT

  19. 19

    Deleting a specific rows and columns from a data-set using Matlab

  20. 20

    How to exclude rows/columns from numpy.ndarray data

  21. 21

    Remove "duplicated" rows from data frame (they differ in few columns)

  22. 22

    SQL or MSEXCEL transpose data from rows to columns NOT PIVOT nor TRANSFORM

  23. 23

    Remove NAs from data frame without deleting entire rows/columns

  24. 24

    Event data from rows to columns by ID in R, Reshape?

  25. 25

    Pandas Create Columns From Rows in Other Data Frame with Criteria

  26. 26

    Remove rows from a data frame that contain duplicate information across the columns

  27. 27

    R: aggregation (median) of data.frame rows from >2 columns

  28. 28

    Excel VBA code to transpose data from rows to columns

  29. 29

    How to move Excel 2010 data from rows into 2 columns only?

HotTag

Archive