Results 1 to 10 of 10

UDF to List Unique Values Unsorted within a table

Threaded View

  1. #1
    Registered User
    Join Date
    10-19-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    10

    UDF to List Unique Values Unsorted within a table

    Hi,

    I have been using this UDF to get a list of sorted unique values from a field BATCH in a table TRANSACTIONS in a separate sheet -

    Function FilterUniqueSort(ByRef rng As Range, ByVal ref As Long)
        Dim e, x
        With CreateObject("System.Collections.ArrayList")
            For Each e In rng.Value
                If e <> "" Then
                    If IsNumeric(e) Then e = Format$(e, String(20, "0") & _
                    ".000000000")
                    If Not .Contains(e) Then .Add e
                End If
            Next
            .Sort
            x = .ToArray
            If .Count >= ref And ref <= .Count Then
                If IsNumeric(x(ref - 1)) Then x(ref - 1) = Val(x(ref - 1))
                FilterUniqueSort = x(ref - 1)
            Else
                FilterUniqueSort = ""
            End If
        End With
    End Function
    In a separate sheet, I just copy this formula =FilterUniqueSort(Transactions[Batch],ROW(AD1)) down as many rows as necessary, and because unlike most UDFs, the formula doesn't need to be pasted inside an array, so I can use the results as another table (array formulas don't work in tables). It's been working great for the last 10 months, but if there are more than a few thousand records, it can be quite slow.

    I want to speed up the processing by removing the sorting function, and I have tried to edit the VBA so it no longer sorts, but with no success. Does someone know how to remove the sorting function from the VBA? I would be really appreciative. I spent 3 hours last week trawling google (including this forum) for alternate code, but with no success.

    Thanks in advance for your assistance,
    Stuart
    Last edited by stu40; 10-26-2015 at 12:21 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formula to Return certain Values from Unsorted Table
    By cakonopka in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-10-2015, 04:48 PM
  2. Grouping data according to unique user ID in an unsorted Excel 2010 table
    By Rogervanduffel in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-19-2015, 06:02 AM
  3. [SOLVED] make list of values corresponding to unique values in parallel list
    By johnandrews in forum Excel General
    Replies: 3
    Last Post: 11-18-2014, 09:46 AM
  4. [SOLVED] Extract unique values from a table and list along a row
    By doctorblyth in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2013, 04:33 PM
  5. create a "live" input table for product prices from a list of automatic unique values
    By andymcnichol in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-11-2012, 06:13 AM
  6. 3 columns: None contain unique values, but I need a list of every unique set
    By mathematician in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-15-2012, 04:47 PM
  7. macro to generate sorted table from unsorted list?
    By JGCA in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2009, 11:36 AM

Tags for this Thread

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