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 -
In a separate sheet, I just copy this formula =FilterUniqueSort(Transactions[Batch],ROW(AD1)) down as many rows as necessary, and because it doesn't need an array, I can use the results within a table. 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 now by removing the sorting function, and I have tried to edit the code so it no longer sorts, but with no success. If someone could find a way to remove the sorting function from the code, I would be really appreciative. I spent 3 hours yesterday trawling google for alternate code, but with no success.
Thanks in advance for your assistance,
Stuart
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 -
Code:
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
I want to speed up the processing now by removing the sorting function, and I have tried to edit the code so it no longer sorts, but with no success. If someone could find a way to remove the sorting function from the code, I would be really appreciative. I spent 3 hours yesterday trawling google for alternate code, but with no success.
Thanks in advance for your assistance,
Stuart