#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Array sort

Dave Peterson wrote:
There are lots of sort routines that you can find via google.

This is one:

Option Explicit
Sub testme()

Dim myArr1 As Variant
Dim iCtr As Long
Dim jCtr As Long
Dim Temp As Variant

myArr1 = Array("S", "E", "A", "R", "C", "H")

For iCtr = LBound(myArr1) To UBound(myArr1) - 1
For jCtr = iCtr + 1 To UBound(myArr1)
If myArr1(iCtr) myArr1(jCtr) Then
Temp = myArr1(iCtr)
myArr1(iCtr) = myArr1(jCtr)
myArr1(jCtr) = Temp
End If
Next jCtr
Next iCtr

For iCtr = LBound(myArr1) To UBound(myArr1)
MsgBox iCtr & "--" & myArr1(iCtr)
Next iCtr

End Sub

It actually sorts the original array--is that a problem?

kenrock wrote:

Hi, I have some queries about the use of strings and arrays:-
1. Is there a simple way to use VBA Code to sort a string eg "SEARCH" to
"AECHRS" ie is there a worksheet function which can be called?
2. If text is in an array eg myArray1(6) = ("S","E","A","R","C","H"),
how can I produce myArray2(6) = ("A","E","C","H","R","S")?
Any thoughts would be greatly appreciated.
Regards. Kenrock

*** Sent via Developersdex http://www.developersdex.com ***



Hi Dave,
Many thanks for your reply and apologies for the delay in coming back to
you. I have been distracted by other things but now I have the time to
get to grips with your response.
Regards, Kenrock
Reply
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
Sort array with 2 dimensions? eclipse Excel Programming 4 October 27th 05 04:19 PM
Array... Sort of... Egon Excel Worksheet Functions 2 October 19th 05 05:47 PM
How to sort ListBox or Array? NEED Excel Programming 1 December 16th 04 08:13 PM
Sort an Array [email protected] Excel Programming 0 November 18th 04 01:20 AM
sort an array clui[_15_] Excel Programming 2 January 7th 04 11:49 AM


All times are GMT +1. The time now is 10:38 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"