I'm trying to assign a range to an array (by values) in VBA, and use the sort method on it. I can't sort it in the sheet since it is based on formulas and Excel keeps trying to sort based on the formulas.
So something like this would be succinct, but it doesn't work.
Dim TU As Variant
TU = Range("Thermal_Units").Sort key1:=Range("Thermal_Units").Columns(28), order1:=xlAscending, Header:=xlNo
Does anyone know how to accomplish the assignment and the sort? Or am I forced to just write a sort routine to apply after the assignment?
TU = Evaluate("SORT(Thermal_Units,28)")maybeRange("Thermal_Units")to a new sheet, load into an array after sorting the table, then remove the sheetTU = Application.Sort(Range("Thermal Units"), 28, 1). If this doesn't work as expected, you could tryTU = Range("Thermal Units").Value: TU = Application.Sort(TU, 28, 1)or use another Variant for the 2nd equation. BTW, descending is-1.