Create Array of Distinct Values in a Column Based on Another Column

zgadson

Board Regular
Joined
Jul 16, 2015
Messages
68
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Could use some help! Prefer to use a formula over VBA, but I'm not sure if that's possible. Based on the attached screenshot, I'd like to create a new column with an array of Aisles based on matching ITM.DESC.
IE, for my item "23 OZ ORGANIC MARINARA", I'd like a new column to show "M1, M2"

If I need to do it with VBA that's fine, but I'd like to avoid having to manually run a macro every time I update my sheet.

Thanks!
Zach
 

Attachments

  • Untitled.png
    Untitled.png
    16.7 KB · Views: 4

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
How about
+Fluff v2.xlsm
ABCDE
1AisleIn use?LatitudeItm.DescColumn1
2CA110SAYes54.615912CumbriaCA110SA
3DY140JBYes52.409181ShropshireDY140JB
4OL146XBYes53.680058West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
5DL131JZYes54.73854County DurhamDL131JZ, DH85EJ, DL120RY
6NE479LQYes54.895638NorthumberlandNE479LQ
7S361GJYes53.472455South YorkshireS361GJ
8BD63FHYes53.767997West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
9BD206QXYes53.88118West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
10OL139RNYes53.692248LancashireOL139RN
11HD73EBNo53.582804West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
12TQ137PEYes50.544961DevonTQ137PE
13DH85EJYes54.853973County DurhamDL131JZ, DH85EJ, DL120RY
14DL85JZYes54.323588North YorkshireDL85JZ, DL83SH
15DL83SHYes54.299948North YorkshireDL85JZ, DL83SH
16ST102LAYes53.046617StaffordshireST102LA
17HD33GSYes53.659793West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
18HX77LPNo53.748059West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
19DL120RYYes54.623951County DurhamDL131JZ, DH85EJ, DL120RY
Work
Cell Formulas
RangeFormula
E2:E19E2=TEXTJOIN(", ",1,FILTER([Aisle],[Itm.Desc]=[@[Itm.Desc]]))
 
Upvote 0
Tried it but got an error saying "That function isn't valid". I'm using Excel 2019 if that makes a difference.
 
Upvote 0
Filter is only available in 365, try
+Fluff v2.xlsm
ABCDE
1AisleIn use?LatitudeItm.DescColumn1
2CA110SAYes54.615912CumbriaCA110SA
3DY140JBYes52.409181ShropshireDY140JB
4OL146XBYes53.680058West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
5DL131JZYes54.73854County DurhamDL131JZ, DH85EJ, DL120RY
6NE479LQYes54.895638NorthumberlandNE479LQ
7S361GJYes53.472455South YorkshireS361GJ
8BD63FHYes53.767997West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
9BD206QXYes53.88118West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
10OL139RNYes53.692248LancashireOL139RN
11HD73EBNo53.582804West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
12TQ137PEYes50.544961DevonTQ137PE
13DH85EJYes54.853973County DurhamDL131JZ, DH85EJ, DL120RY
14DL85JZYes54.323588North YorkshireDL85JZ, DL83SH
15DL83SHYes54.299948North YorkshireDL85JZ, DL83SH
16ST102LAYes53.046617StaffordshireST102LA
17HD33GSYes53.659793West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
18HX77LPNo53.748059West YorkshireOL146XB, BD63FH, BD206QX, HD73EB, HD33GS, HX77LP
19DL120RYYes54.623951County DurhamDL131JZ, DH85EJ, DL120RY
Work
Cell Formulas
RangeFormula
E2:E19E2=TEXTJOIN(", ",1,IF([Itm.Desc]=[@[Itm.Desc]],[Aisle],""))
 
Upvote 0
Gets me one step further at least! Aisles repeat as if it's including every aisle for that Item. I'm not an idiot when it comes to formulas, but this one is eluding me. Even tried an INDEX, MATCH and it still adds repeated Aisles, but with this at least the count of repeats seems to match the number of times an item is in an Aisle.

VBA Code:
=TEXTJOIN(", ",1,IF([ITM.CODE]=[@[ITM.CODE]],INDEX([AISLE],MATCH(0,COUNTIF($B$3:B9,[AISLE]),0)), ""))

Nothing more annoying than messing with a formula for hours at a time, so I do sincerely appreciate your help!
 

Attachments

  • Untitled.png
    Untitled.png
    13.7 KB · Views: 4
Upvote 0
I'm afraid I have no idea how to do that with 2019, unless your happy with a UDF.
 
Upvote 0
Nah, trying to keep it simple. However, I did actually find a workaround using INDEX, MATCH on a hidden sheet to make a list of unique values, then took your TEXTJOIN suggestion to manually pull everything into a single cell, delineated with commas between. =A1 & ", " & A2 & ", " ... etc.

Thanks again!
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,667
Messages
6,120,810
Members
448,990
Latest member
rohitsomani

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