Results 1 to 3 of 3

Add Data validation of Alphabetically Sort Unique values using Array Formula

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-20-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    275

    Question Add Data validation of Alphabetically Sort Unique values using Array Formula

    Hello Excel Experts,
    First of all, i thank each member for their suggestion to figure out issue in below post. Currently i am too struggling with same issue and after going through below post i found the issue was with drop downs..!!
    https://www.excelforum.com/excel-pro...ver-as-mu.html

    Below is the code which i currently use to get sorted unique values and its definitely causing the error. How can i create drop downs (Unique and Sorted) using Array formulas and in-turn add into VBA..? Sorry i am not that used to Array formulas.. Please help.. By the way i have 5000 rows (dynamic) of data and unique values among them may be 50 or so..

    Function Sorted(Rng As Range, Optional Delim As String = ",") As String
      Dim X As Long, Arr As Variant, Uniques As Variant
      Arr = Rng.Value
            With CreateObject("Scripting.Dictionary")
              For X = 1 To UBound(Arr)
                .Item(Arr(X, 1)) = 1
              Next
              Uniques = .Keys
            End With
            With CreateObject("System.Collections.ArrayList")
              For X = LBound(Uniques) To UBound(Uniques)
                .Add Uniques(X)
              Next
              .Sort
              Sorted = Join(.ToArray, Delim)
              If left(Sorted, 1) = Delim Then Sorted = Mid(Sorted, 2)
            End With
    End Function
    
    Sub allDropDowns()
     Dim unique_string1 As String
    
     Worksheets("SOMENAME").Select
     On Error Resume Next
        Worksheets("SOMENAME").ShowAllData
      On Error GoTo 0
         unique_string1 = Sorted(Worksheets("SOMENAME").Range("A4", Worksheets("SOMENAME").Cells(Rows.Count, "A").End(xlUp)))
    
     With Worksheets("Macro").Range("C9").Validation
            .Delete
            .Add xlValidateList, Formula1:="All," & unique_string1
     End With
    Last edited by Pepe Le Mokko; 03-24-2020 at 03:25 AM. Reason: Shortened title. We know you are looking for XL VBA. Keep to the essentials

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Non Array Formula to pull unique values and sort in a range
    By bjnockle in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-04-2021, 06:15 AM
  2. Non Array Formula to Sort Values Alphabetically
    By bjnockle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-28-2018, 06:21 PM
  3. Data Validation List - Formula to Sort and Return Unique Values in List
    By beewketu in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-14-2015, 04:18 PM
  4. [SOLVED] Dynamic Formula for Getting Unique Items from a list and sort them alphabetically
    By tuckertheguy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-18-2015, 03:57 AM
  5. [SOLVED] Using an array formula to sort alphabetically over multiple columns
    By AliGW in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 02-14-2014, 02:13 PM
  6. [SOLVED] Array formula to extract and sort unique values from two worksheets
    By rshukla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-07-2013, 06:11 AM
  7. [SOLVED] Formula to extract unique values from two excel tabs and sort alphabetically
    By rshukla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-06-2013, 01:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1