It is Possible? Index Match - returning column header

fidelito101

New Member
Joined
Sep 14, 2018
Messages
13
Hello Team!

I have a table that contains Products and parts for manufacturing(sheet1)

Part NumberPart NameTOYOTA 374FTOYOTA 637FNISSAN 1224VOLVO 2650
HU294150-0400CYLINDER11
HU294150-0410CYLINDER11
HU294191-0100CAMSHFT111
HU294191-0070CAMSHAT1
HU294110-0380BEARING COVER1111

<tbody>
</tbody>

And in Sheet2 I need a table like this below:

HU294150-0400CYLINDERTOYOTA 374FNISSAN 1224
HU294150-0410CYLINDERTOYOTA 637FVOLVO 2650
HU294191-0100CAMSHFTTOYOTA 374FTOYOTA 637FNISSAN 1224
HU294110-0380BEARING COVERTOYOTA 374FTOYOTA637FNISSANVOLVO2650
HU294191-0070CAMSHATVOLVO 2650

<tbody>
</tbody>


And if is possible to avoid blank cells.
****** id="cke_pastebin" style="position: absolute; top: 274.4px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
CYLINDER

<tbody>
</tbody>
</body>
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
try PowerQuery

Part NumberPart NameCustom.1Custom.2Custom.3Custom.4
HU294150-0400CYLINDERTOYOTA 374FNISSAN 1224
HU294150-0410CYLINDERTOYOTA 637FVOLVO 2650
HU294191-0100CAMSHFTTOYOTA 374FTOYOTA 637FNISSAN 1224
HU294191-0070CAMSHATVOLVO 2650
HU294110-0380BEARING COVERTOYOTA 374FTOYOTA 637FNISSAN 1224VOLVO 2650

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Part Number", "Part Name"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Part Number", "Part Name"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each List.Distinct(Table.Column([Count],"Attribute"))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Count"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4"})
in
    #"Split Column by Delimiter"[/SIZE]
 
Upvote 0
Here's an array formula to try.
This formula must be entered with CTRL-SHIFT-ENTER.
Drag formula across and down cells as needed.

Excel Workbook
ABCDEF
1HU294150-0400CYLINDERTOYOTA 374FNISSAN 1224
2HU294150-0410CYLINDERTOYOTA 637FVOLVO 2650
3HU294191-0100CAMSHFTTOYOTA 374FTOYOTA 637FNISSAN 1224
4HU294110-0380BEARING COVERTOYOTA 374FTOYOTA 637FNISSAN 1224VOLVO 2650
5HU294191-0070CAMSHATVOLVO 2650
Sheet2
Excel Workbook
ABCDEF
1Part NumberPart NameTOYOTA 374FTOYOTA 637FNISSAN 1224VOLVO 2650
2HU294150-0400CYLINDER11
3HU294150-0410CYLINDER11
4HU294191-0100CAMSHFT111
5HU294191-0070CAMSHAT1
6HU294110-0380BEARING COVER1111
Sheet1
 
Upvote 0
Try this (after adjusting the ranges to match your situaion)

Code:
Sub test()
    Dim dataRange As Range, arrData As Variant
    Dim rngOutput As Range, arrOutput As Variant
    Dim rw As Long, lookAt As Long, writeTo As Long, j As Long
    
    Set dataRange = Sheet1.Range("a1").CurrentRegion: Rem adjust
    Set rngOutput = sheet2.Range("A1"): Rem adjust
    
    arrData = dataRange.Value
    arrOutput = dataRange.Offset(1, 0).Value
    
    For rw = 2 To dataRange.Rows.Count
        writeTo = 3
        For lookAt = 3 To dataRange.Columns.Count
            If arrData(rw, lookAt) = 1 Then
                arrOutput(rw - 1, writeTo) = arrData(1, lookAt)
                writeTo = writeTo + 1
            End If
        Next lookAt
        For j = writeTo To dataRange.Columns.Count
            arrOutput(rw - 1, j) = vbNullString
        Next j
    Next rw
    
    rngOutput.Resize(UBound(arrOutput, 1), UBound(arrOutput, 2)).Value = arrOutput
End Sub
 
Upvote 0
Hi AhoyNC

This works perfectly, THANKS A LOT. If no problem, I have another question, my table has 56 products(Fuel Pumps) and more than 300 parts, for example there is a Part Number:294096-0040 Part Name:WASHER and in some product I need 2 or 3 pieces. How to resolve this problem?

Thans for you help.
 
Upvote 0
Could you post a small sample and the out put you are looking for like you did in post#1?
 
Upvote 0
Hi AhoyNC

ABCDE
Part NumberPart NameToyota 374Lombardini 1800VOLVO 920
HU294191-0100CAMSHAFT11
294096-0040WASHER221
HU294198-0010O-RING32

<tbody>
</tbody>


The result that I would like:

ABCD E
Part NumberPart Name
HU294191-0100CAMSHAFTToyota 374VOLVO 920
294096-0040WASHERToyota 374Lombardini 1800VOLVO 920
HU294198-0010O-RINGToyota 374VOLVO 920

<tbody>
</tbody>

****** id="cke_pastebin" style="position: absolute; top: 304px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
O-RING

<tbody>
</tbody>
</body>Thios is an example, the original table has around 400 Parts and 56 customers.

Thanks for helping.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top