0

Question -

Column 1  Column 2
------------------
A          AB
B          PR
C          EF
A          GH
A          JK
C          XY
A          UV
D          YZ

Solution required

Query  Column 2 column 3 column 4 Column 5
  A         AB       GH       JK    UV
  B         PR
  C         EF       XY
  D         YZ

I need Excel formulas, no VBA or programming.

Tried Index & Match formulas which gives me values for one cell in adjacent column but I need to get all the references as mentioned in table.

Need this in a different sheet as a summary.

[This is a Bill of material (BOM) table]

Total 48000 rows and 15 Columns are there in table,while 15000 rows are unique.We also need only 2 columns out of 15 for summary purpose.Some cells are referred 20 times or more so need all these values to be populated in different columns.

The sheet from where i try to get this data is linked to another source file using MS Query.

PS : Apologies for providing no information in original query.

3
  • You haven't given any actual question or provided much details. For example -- are you looking for regular spreadsheet formulas, array formulas, or a VBA result? Is the "Solution required" on a different, summary sheet, or is the goal to modify the original sheet? What have you tried to do (beyond posting an implicit question to Stack Overflow) and where did you run into difficulties? Jul 8, 2015 at 3:50
  • This is asked and answered in one form or another quite frequently. A recent example would be Transposing columns to avoid redundancies. If that doesn't sort you out, research the term 'transpose' in this site's Excel forum.
    – user4039065
    Jul 8, 2015 at 4:09
  • I need Excel formulas.I tried Index & Match formulas which gives me one column but not sure how to get all references.Need this in a different sheet compared to the sheet from where i have to get the details. Jul 8, 2015 at 7:53

2 Answers 2

0

This code will create a new sheet called RowsToColumns with your summerised data on it.

Sub PostRowsToColumns()
Dim X As Long, Y As Long, MyArr As Variant
ActiveSheet.Copy After:=Sheets(Worksheets.Count)
ActiveSheet.Name = "RowsToColumns"
Range("A2:B" & Range("A" & Rows.Count).End(xlUp).Row).Sort Range("A1")
Y = 2
For X = 2 To Range("A" & Rows.Count).End(xlUp).Row
    If Range("A" & X).text <> Range("A" & X).Offset(-1, 0).text Then
        MyArr = Application.Transpose(Range("B" & X).Resize(WorksheetFunction.CountIf(Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row), Range("A" & X)), 1))
        Range("D" & Y) = Range("A" & X).text
        If Range("B" & X).Resize(WorksheetFunction.CountIf(Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row), Range("A" & X)), 1).Rows.Count > 1 Then
            Range("E" & Y).Resize(1, UBound(MyArr)) = MyArr
        Else
            Range("E" & Y) = MyArr
        End If
        Y = Y + 1
    End If
Next
Columns("A:C").Delete Shift:=xlToLeft
End Sub
1
  • 1
    Many many thanks..i got same requirement today and here is the exact solution waiting even after 3.5 years :) Jan 19, 2019 at 11:16
0

Assuming your column 1 is A2:A9 and column 2 is B2:B9 then with a "unique list" of column 1 values starting at A11 you can use this formula in B11, confirmed with CTRL+SHIFT+ENTER and copied down and across

=IFERROR(INDEX($B$2:$B$9,SMALL(IF($A$2:$A$9=$A11,ROW($A$2:$A$9)-ROW($A$2)+1),COLUMNS($B11:B11))),"")

You can expand for larger ranges (or for data in other worksheets) but if you have a large number of such formulas it might slow down your workbook considerably

See example file here:

https://www.dropbox.com/s/f1hqut8s6u0n7ln/Code%20List.xlsx?dl=0

1
  • Hi Barry, Many thanks...this is similar to what i am looking for.Unfortunately as i have more than 20000 unique values in column A excel is taking so much time.Any way thanks again for the formula. Do we have any formula without array? Jul 8, 2015 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.