Extract unique values from multiple columns in one row

Grapez

New Member
Joined
Nov 13, 2008
Messages
9
Hi,

I have a sheet with 15000 rows and in column AV-CK have values which can contain duplicates.

I'm trying to get in CL the unique values from AV-CK (merged / concatenated)

Everything I've found so far (advanced filter, autofilter, remove duplicates) work on a range of values in one column.....but I have them in a row.

Any suggestions on how to best do this? It's basically a concatenate of unique values.

Thanks,
Henk-Jan
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this

Code:
Sub Extract_unique_values()
  Dim r As Range, a() As Variant, i As Long, j As Long, dict As Object
  Set r = Range("AV1:CK" & Range("AV" & Rows.Count).End(xlUp).Row)
  Set dict = CreateObject("scripting.dictionary")
  a = r.Value
  For i = 1 To UBound(a)
    For j = 1 To r.Columns.Count
      dict(a(i, j)) = dict(a(i, j))
    Next
  Next
  Range("CL1").Resize(dict.Count) = Application.Transpose(dict.Keys)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,659
Messages
6,120,784
Members
448,992
Latest member
prabhuk279

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