Excel VBA Quickest way to sort an array of numbers in descending order?

You could use System.Collections.ArrayList:

Dim arr As Object
Dim cell As Range

Set arr = CreateObject("System.Collections.ArrayList")

' Initialise the ArrayList, for instance by taking values from a range:
For Each cell In Range("A1:F1")
    arr.Add cell.Value
Next

arr.Sort
' Optionally reverse the order
arr.Reverse

This uses Quick Sort.

Leave a Comment