• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Show repeating values once in data validation drop down list

In the attached file, in cell H3, I have a data validation drop down list. This references a named range which has repeating values. In the data validation drop down, I would like for duplicate values to be shown only once.

Is there a way to do this?
 

Attachments

  • Chandoo.org.xlsx
    8.5 KB · Views: 7
A way that will soon be available to Office 365 users is to use the new(ish) array function
= UNIQUE(list)
This can be tidied up a bit more using
= SORT( UNIQUE(list) )
If the anchor cell of the resulting spilt array were 'validate', then
=validate#
will work as a sorted, dynamic validation list.
 
Try this macro
Code:
Option Explicit

Sub data_val()
Dim My_list As Object
Dim Rg As Range, CL As Range

 Set Rg = Range("C3", Range("c2").End(4))
 Set My_list = CreateObject("System.Collections.ArrayList")

With My_list
  For Each CL In Rg
    If Not .Contains(CL.Value) Then .Add CL.Value
  Next
End With
    
With Cells(2, "H").Validation
    .Delete
    .Add 3, Formula1:=Join(My_list.ToArray, ",")
End With

Set My_list = Nothing
End Sub
 

Attachments

  • Dynamic_data_val.xlsm
    21.3 KB · Views: 5
Back
Top