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)

[TABLE="class: grid, width: 800, align: center"]
<tbody>[TR]
[TD]Part Number[/TD]
[TD]Part Name[/TD]
[TD]TOYOTA 374F[/TD]
[TD]TOYOTA 637F[/TD]
[TD]NISSAN 1224[/TD]
[TD]VOLVO 2650[/TD]
[/TR]
[TR]
[TD]HU294150-0400[/TD]
[TD]CYLINDER[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HU294150-0410[/TD]
[TD]CYLINDER[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]HU294191-0100[/TD]
[TD]CAMSHFT[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HU294191-0070[/TD]
[TD]CAMSHAT[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]HU294110-0380[/TD]
[TD]BEARING COVER[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]

And in Sheet2 I need a table like this below:

[TABLE="class: grid, width: 800, align: center"]
<tbody>[TR]
[TD]HU294150-0400[/TD]
[TD]CYLINDER[/TD]
[TD]TOYOTA 374F[/TD]
[TD]NISSAN 1224[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HU294150-0410[/TD]
[TD]CYLINDER[/TD]
[TD]TOYOTA 637F[/TD]
[TD]VOLVO 2650[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HU294191-0100[/TD]
[TD]CAMSHFT[/TD]
[TD]TOYOTA 374F[/TD]
[TD]TOYOTA 637F[/TD]
[TD]NISSAN 1224[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HU294110-0380[/TD]
[TD]BEARING COVER[/TD]
[TD]TOYOTA 374F[/TD]
[TD]TOYOTA637F[/TD]
[TD]NISSAN[/TD]
[TD]VOLVO2650
[/TD]
[/TR]
[TR]
[TD]HU294191-0070[/TD]
[TD]CAMSHAT[/TD]
[TD]VOLVO 2650[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


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;">[TABLE="class: grid, width: 800, align: center"]
<tbody>[TR]
[TD]CYLINDER[/TD]
[/TR]
</tbody>[/TABLE]
</body>
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
try PowerQuery

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#70AD47]Part Number[/td][td=bgcolor:#70AD47]Part Name[/td][td=bgcolor:#70AD47]Custom.1[/td][td=bgcolor:#70AD47]Custom.2[/td][td=bgcolor:#70AD47]Custom.3[/td][td=bgcolor:#70AD47]Custom.4[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]HU294150-0400[/td][td=bgcolor:#E2EFDA]CYLINDER[/td][td=bgcolor:#E2EFDA]TOYOTA 374F[/td][td=bgcolor:#E2EFDA]NISSAN 1224[/td][td=bgcolor:#E2EFDA][/td][td=bgcolor:#E2EFDA][/td][/tr]

[tr=bgcolor:#FFFFFF][td]HU294150-0410[/td][td]CYLINDER[/td][td]TOYOTA 637F[/td][td]VOLVO 2650[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]HU294191-0100[/td][td=bgcolor:#E2EFDA]CAMSHFT[/td][td=bgcolor:#E2EFDA]TOYOTA 374F[/td][td=bgcolor:#E2EFDA]TOYOTA 637F[/td][td=bgcolor:#E2EFDA]NISSAN 1224[/td][td=bgcolor:#E2EFDA][/td][/tr]

[tr=bgcolor:#FFFFFF][td]HU294191-0070[/td][td]CAMSHAT[/td][td]VOLVO 2650[/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]HU294110-0380[/td][td=bgcolor:#E2EFDA]BEARING COVER[/td][td=bgcolor:#E2EFDA]TOYOTA 374F[/td][td=bgcolor:#E2EFDA]TOYOTA 637F[/td][td=bgcolor:#E2EFDA]NISSAN 1224[/td][td=bgcolor:#E2EFDA]VOLVO 2650[/td][/tr]
[/table]


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

[TABLE="class: grid, width: 800, align: center"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]Part Number[/TD]
[TD]Part Name[/TD]
[TD]Toyota 374[/TD]
[TD]Lombardini 1800[/TD]
[TD]VOLVO 920[/TD]
[/TR]
[TR]
[TD]HU294191-0100[/TD]
[TD]CAMSHAFT[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]294096-0040[/TD]
[TD]WASHER[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]HU294198-0010[/TD]
[TD]O-RING[/TD]
[TD]3[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]


The result that I would like:

[TABLE="class: grid, width: 800, align: center"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D [/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]Part Number[/TD]
[TD]Part Name[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HU294191-0100[/TD]
[TD]CAMSHAFT[/TD]
[TD]Toyota 374[/TD]
[TD]VOLVO 920[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]294096-0040[/TD]
[TD]WASHER[/TD]
[TD]Toyota 374[/TD]
[TD]Lombardini 1800[/TD]
[TD]VOLVO 920[/TD]
[/TR]
[TR]
[TD]HU294198-0010[/TD]
[TD]O-RING[/TD]
[TD]Toyota 374[/TD]
[TD]VOLVO 920[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

****** id="cke_pastebin" style="position: absolute; top: 304px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE="class: grid, width: 800, align: center"]
<tbody>[TR]
[TD]O-RING[/TD]
[/TR]
</tbody>[/TABLE]
</body>Thios is an example, the original table has around 400 Parts and 56 customers.

Thanks for helping.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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