Forum Discussion

SergS's avatar
SergS
Copper Contributor
Jul 09, 2021

UNIQUE Function in Data Validation

I'm trying to use a Name, containing UNIQUE formula in Data Validation, but it throughs an error: The Source Currently Evaluates To an Error. 

Is it a bug?

 

 

  • SergS 

    That's by design. UNIQUE() function returns an array, and data validation doesn't work wit arrays. It works with references on ranges. Thus you need to land returned by UNIQUE() array into the range and use reference on this range. For example, if in A1 is =UNIQUE(something) in data validation you could use the list with reference on spill =$A$1#

  • SergS 

    That's by design. UNIQUE() function returns an array, and data validation doesn't work wit arrays. It works with references on ranges. Thus you need to land returned by UNIQUE() array into the range and use reference on this range. For example, if in A1 is =UNIQUE(something) in data validation you could use the list with reference on spill =$A$1#

    • SergS's avatar
      SergS
      Copper Contributor

      SergeiBaklan yes I did such a way with several helper sheets having TRANSPOSE(UNIQUE) and =$A$1#. It works, but bit slowly. Hoped there could be more elegant solution.

       

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    SergS 

    I'm not sure, but if UNIQUE doesn't recognize the numbers then there will be an error like this,

    as far as I can dare remember.

     

    It could be that there are numbers in one column

    and numbers are entered as text in the other column.

     

    Hope this tip can help you.

     

    Nikolino

    I know I don't know anything (Socrates)

    * Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

  • Jadore's avatar
    Jadore
    Copper Contributor
    You can solve this by using the offset formula in your data validation. =OFFSET(INDEX(INDIRECT(A1);1);;;COUNTIF(INDIRECT(A1);"?*");)
    Where A1 is a text referring to a array defined in >Formulas>Name Manager. But you could use a column of a table instead. (=OFFSET(INDEX(tableName[columnName];1);;;COUNTIF(tableName[columnName];"?*");)
    • Jadore 

      OFFSET/INDIRECT is even more slower. Didn't test the performance, but I guess significantly, depends on concrete data.

      Fortunately in modern Excel we may not care about UNIQUE, it removes duplicates by default. 

      • Tim__Bailey's avatar
        Tim__Bailey
        Copper Contributor

        SergeiBaklan 
        This only appears to be correct when refencing the cells directly, when attempting to reference a table (thus requiring use of INDIRECT) it provides all values, to include duplicated content.

Share

Resources