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
Bookmarks