How to pull options associated with a product

joshbjames

New Member
Joined
Jul 25, 2017
Messages
33
I am in excel trying to pull a list of options for each product I have. For example -

Column A/Column B
Pants/Red
Pants/Blue
Pants/Green
Shorts/Orange
Shorts/Yellow
Shirt/Striped
Shirt/Polkadots
Shirt/Chevron
Shirt/Floral

What I would like is to be able to use my list of product names in Column A and call the options out to the side like below.

Column A/Column B/Column C/Column D/ Column E
Pants/Red/Blue/Green
Shorts/Orange/Yellow
Shirt/Striped/Polkadots/Chevron/Floral

They could even be comma separated, so I could divide them into columns

Pants,Red,Blue,Green
Shorts,Orange,Yellow
Shirt,Stripped,Polkadots,Chevron,Floral

Any help would be greatly appreciated!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
How about
Code:
Sub GetOptions()

   Dim Cl As Range
   Dim Itm As Variant
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) Then
            .Add Cl.Value, Cl.Offset(, 1).Value
         Else
            .Item(Cl.Value) = .Item(Cl.Value) & "|" & Cl.Offset(, 1).Value
         End If
      Next Cl
      Range("H2").Resize(.Count).Value = Application.Transpose(.keys)
      For Each Itm In .items
         Range("I" & Rows.Count).End(xlUp).Offset(1).Resize(, UBound(Split(Itm, "|")) + 1).Value = Split(Itm, "|")
      Next Itm
   End With
End Sub
This will create a list of items & options starting in col H
 
Upvote 0
This formulaic solution might work for you. You will need to create the unique list of each piece of Apparel as I did for ColumnD. Copy E2 downwards.

ABCDE
1ApparelColourUnique ListColours
2PantsRedPantsRed, Blue, Green
3PantsBlueShortsOrange, Yellow
4PantsGreenShirtStriped, Polkadots, Chevron, Floral
5ShortsOrange
6ShortsYellow
7ShirtStriped
8ShirtPolkadots
9ShirtChevron
10ShirtFloral

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet56

Array Formulas
CellFormula
E2{=TEXTJOIN(", ",1,IF(D2=$A$2:$A$10,$B$2:$B$10,""))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
For some reason, it is returning the value #NAME ?

I've tinked a little, but I have it set up so I could copy your formula exactly and it had the same problem.
 
Upvote 0
What version of Excel are you using?
TextJoin only came in with 2016
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,495
Members
449,088
Latest member
Melvetica

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