LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting 2D Array

Hi folks. I have been sorting a VBA Array using a bubble sort. I
works fine with when my VBA array is 1-D, but when I change to 2-D it
get a "Subscript out of range" Error.


I have an array called UnitOfferArray

ReDim UnitOfferArray(1 To NumberofRows, 1 To 4)

For X = 1 to 10

Next X


BubbleSort UnitOfferArray

Function BubbleSort(List As Variant)
' Sorts an array using bubble sort algorithm
Dim First As Integer, Last As Integer
Dim i As Integer, j As Integer
Dim Temp As Integer

First = LBound(List)
Last = UBound(List)
For i = 1 To Last - 1
For j = i + 1 To Last
If List(i) List(j) Then
Temp = List(j)
List(j) = List(i)
List(i) = Temp
End If
Next j
Application.StatusBar = "Sorting " & Round(i / Last * 100, 0)
"%"
Next i

End Functio

--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting array function explanation please Ken Johnson Excel Worksheet Functions 4 August 23rd 08 04:20 PM
sorting array formula driller Excel Worksheet Functions 2 July 7th 08 12:10 AM
Sorting within an array Steve Excel Discussion (Misc queries) 1 May 31st 07 12:49 PM
Sorting Names in an Array Philippe Lhermie Excel Programming 6 July 20th 03 02:40 PM
Sorting a 2-dimensional array Vasant Nanavati[_2_] Excel Programming 3 July 12th 03 08:27 PM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"