Unique values from column where cells have multiple values with a delimiter

ausswe

New Member
Joined
Feb 19, 2013
Messages
35
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,
I've been sourcing around to figure out how to use a formula to get a unique list with values in a column where some cells have multiple values in the same cell with "; " as a delimiter between them. Would anyone have any ideas?

Example:

A (unique values from B)B
Sarskild boendeformSarskild boendeform; Trygghetslarm; Boendestod; Matdistribution
TrygghetslarmMatdistribution
BoendestodSarskild boendeform; Trygghetslarm; Matdistribution
MatdistributionTrygghetslarm
Boendestod; Matdistribution
Sarskild boendeform
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
the spreadsheet contains approx. 5600 rows.
Perhaps then you could consider a user-defined function like this? (It will not work on your MacOS platform though, only Windows)

VBA Code:
Function UniqueList(rng As Range, Optional Delim As String = ";") As Variant
  Dim d As Object
  Dim a As Variant, itm As Variant
  Dim i As Long
 
  a = rng.Value
  Set d = CreateObject("Scripting.Dictionary")
  d.CompareMode = 1
  For i = 1 To UBound(a)
    For Each itm In Split(a(i, 1), Delim)
      d(LTrim(itm)) = 1
    Next itm
  Next i
  UniqueList = Application.Transpose(d.keys)
End Function

ausswe.xlsm
AB
1A (unique values from B)B
2Sarskild boendeformSarskild boendeform; Trygghetslarm; Boendestod; Matdistribution
3TrygghetslarmMatdistribution
4BoendestodSarskild boendeform; Trygghetslarm; Matdistribution
5MatdistributionTrygghetslarm
6Boendestod; Matdistribution
7Sarskild boendeform
Sheet3
Cell Formulas
RangeFormula
A2:A5A2=UniqueList(B2:B7)
Dynamic array formulas.


Note that the function has an option to use a different delimiter so it could be used like this as well

ausswe.xlsm
AB
1A (unique values from B)B
2Sarskild boendeformSarskild boendeform|Trygghetslarm|Boendestod|Matdistribution
3TrygghetslarmMatdistribution
4BoendestodSarskild boendeform|Trygghetslarm|Matdistribution
5MatdistributionTrygghetslarm
6Boendestod|Matdistribution
7Sarskild boendeform
Sheet4
Cell Formulas
RangeFormula
A2:A5A2=UniqueList(B2:B7,"|")
Dynamic array formulas.
 
Upvote 1
Microsoft 365 Apps for enterprise, subscription. Build 2208.
 
Upvote 0
Microsoft 365 Apps for enterprise, subscription. Build 2208.

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Hi,
I've been sourcing around to figure out how to use a formula to get a unique list with values in a column where some cells have multiple values in the same cell with "; " as a delimiter between them. Would anyone have any ideas?

Example:

A (unique values from B)B
Sarskild boendeformSarskild boendeform; Trygghetslarm; Boendestod; Matdistribution
TrygghetslarmMatdistribution
BoendestodSarskild boendeform; Trygghetslarm; Matdistribution
MatdistributionTrygghetslarm
Boendestod; Matdistribution
Sarskild boendeform
enter the following formula:

=UNIQUE(FILTERXML("<root><s>"&SUBSTITUTE(A:A,"; ","</s><s>")&"</s></root>","//s")
 
Upvote 0
Have you actually tried that formula? If so how long did it take?
 
Upvote 0
How about
Fluff.xlsm
AB
1
2Sarskild boendeformSarskild boendeform; Trygghetslarm; Boendestod; Matdistribution
3TrygghetslarmMatdistribution
4BoendestodSarskild boendeform; Trygghetslarm; Matdistribution
5MatdistributionTrygghetslarm
6Boendestod; Matdistribution
7Sarskild boendeform
8
Main
Cell Formulas
RangeFormula
A2:A5A2=UNIQUE(TEXTSPLIT(TEXTJOIN("; ",,B2:B100),,"; "))
Dynamic array formulas.
 
Upvote 0
Try using the below :

Book2
AB
1Sarskild boendeformSarskild boendeform; Trygghetslarm; Boendestod; Matdistribution
2TrygghetslarmMatdistribution
3BoendestodSarskild boendeform; Trygghetslarm; Matdistribution
4MatdistributionTrygghetslarm
5Boendestod; Matdistribution
6Sarskild boendeform
Sheet1
Cell Formulas
RangeFormula
A1:A4A1=UNIQUE(TRIM(TEXTSPLIT(TEXTJOIN(";",,B1:B6),,";")))
Dynamic array formulas.
 
Upvote 0
Thanks all, so option 1 (UNIQUE(FILTERXML("<root><s>"&SUBSTITUTE(A:A,"; ","</s><s>")&"</s></root>","//s")) seems to work, took around 1 minute to calculate with my data and it returned a #VALUE in the middle of the list of values it created, I tried to set the format to General but that didn't help the issue.

Option 2 (UNIQUE(TRIM(TEXTSPLIT(TEXTJOIN(";",,B1:B6),,";")))) returns an #CALC! error saying the function returned text that was longer than the maximum supported length.
 
Upvote 0

Forum statistics

Threads
1,215,836
Messages
6,127,173
Members
449,368
Latest member
JayHo

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