[AccessD] Array sorting

Heenan, Lambert Lambert.Heenan at AIG.com
Thu Aug 7 08:25:16 CDT 2003


Well here is a simple sort routine you can use...

Sub ShellSortArray(a() As Variant)
Dim I As Long, j As Long
Dim Low As Long, Hi As Long
Dim PushPop As Variant
   Low = LBound(a)
   Hi = UBound(a)
   j = (Hi - Low + 1) \ 2
   Do While j > 0
     For I = Low To Hi - j
      If a(I) > a(I + j) Then
         PushPop = a(I)
         a(I) = a(I + j)
         a(I + j) = PushPop
      End If
     Next I
     For I = Hi - j To Low Step -1
      If a(I) > a(I + j) Then
         PushPop = a(I)
         a(I) = a(I + j)
         a(I + j) = PushPop
      End If
     Next I
     j = j \ 2
   Loop
End Sub

If you want an 'Alphametical sort then put it in a standard module with
Option Compare Database at the top, but if you want a binary sort (strictly
ASCII code order) use Option Compare Binary at the top of the module.

Lambert

> -----Original Message-----
> From:	Powell, David (BBM) [SMTP:david.powell at bbm.wapl.com.au]
> Sent:	Wednesday, August 06, 2003 10:41 PM
> To:	AccessD
> Subject:	[AccessD] Array sorting
> 
> Hi Listers, 
> 
> I have a single dimension array of excel cell references stored as string
> values.  I was wondering how you can sort a range that is say A1:C3 from
> A1, A2, A3, B1... C3 to A1, B1, C1, A2, B2...C3?  Any help would be
> greatly appreciated.
> 
> 
> regards 
> 
> David 
> 
> ---------------------------------------------------- 
> David Powell 
> Computing Support Officer 
> Worsley Alumina Pty Ltd 
> Bauxite Mine 
> Boddington WA 6390 
> Ph: +61 8 9734 8269 
> FAX: +61 8 9734 8250 
> <Mailto:david.powell at bbm.wapl.com.au> 
> WAPL Web Page <http://www.wapl.com.au> 
> ---------------------------------------------------- 
> <<Powell, David (BBM).vcf>> 
> 
> 
> 
> NOTICE - This message and any attached files may contain information that
> is confidential and/or subject of legal privilege 
> intended only for use by the intended recipient. If you are not the
> intended recipient or the person responsible for delivering 
> the message to the intended recipient, be advised that you have received
> this message in error and that any dissemination, 
> copying or use of this message or attachment is strictly forbidden, as is
> the disclosure of the information therein. 
> If you have received this message in error please notify the sender
> immediately and delete the message
> Worsley Alumina Pty Ltd ABN 58 008 905 155 is the manager of the Worsley
> Joint Venture - Bauxite/Alumina Operation.
> Liability and responsibility of the Joint Venturers is several in
> accordance with the following schedule of participating interests:
> Billiton Aluminium (RAA) Pty Ltd 56 percent, Billiton Aluminium (Worsley)
> Pty Ltd 30 percent, 
> Kobe Alumina Associates (Australia) Pty Limited 10 percent, Nissho Iwai
> Alumina Pty Limited 4 percent.
>  << File: Powell, David (BBM).vcf >>  << File: ATT1202729.txt >> 


More information about the AccessD mailing list