Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I had a 2D array which I sorted descending using the 9th column. I hav
now expanded the array to include 5 elements. I still want to sort th array as I originally did but am not sure what changes I have to mak to the call statment and the bubble sort to ensure that code contintue to simply sort the 2D portion of the array. The working code below i what I have for the original 2D array. Call BubbleSort2D(UnitOfferArray, 9) Function BubbleSort2D(UnitOfferArray As Variant, col As Long) ' Sorts an array using bubble sort algorithm in descending order usin column as sort criteria Dim First As Integer, Last As Integer Dim i As Integer, j As Integer Dim Temp As Variant First = LBound(UnitOfferArray, 1) Last = UBound(UnitOfferArray, 1) For i = 1 To Last - 1 For j = i + 1 To Last If UnitOfferArray(i, col) < UnitOfferArray(j, col) Then For k = 1 To UBound(UnitOfferArray, 2) Temp = UnitOfferArray(j, k) UnitOfferArray(j, k) = UnitOfferArray(i, k) UnitOfferArray(i, k) = Temp Next k End If Next j Next i End Functio -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorting a portion of a worksheet | Excel Worksheet Functions | |||
Sorting within an array | Excel Discussion (Misc queries) | |||
Sorting a portion of a range | Excel Worksheet Functions | |||
Sorting 2D Array | Excel Programming | |||
Sorting Names in an Array | Excel Programming |