11-15-2011, 05:03 PM
(This post was last modified: 05-29-2012, 03:39 PM by v.swaminathan.)
Hi.. Please let me know if the below code works for you...
You would be required to pass/specify the numbers to the variable "InputNumbers"
'Code Starts Here
'Code Ends Here
Thanks and Regards,
Swami
You would be required to pass/specify the numbers to the variable "InputNumbers"
'Code Starts Here
Code:
Option Explicit
Dim InputNumbers, SplitInputNumbers, ArrayCount, ReSort, iterInputNum, Num1, Num2
InputNumbers = "6,20,30,5,80,56,22,12,34,54"
SplitInputNumbers = Split(InputNumbers, ",")
ArrayCount = UBound(SplitInputNumbers)
ReSort = "YES"
While ReSort = "YES"
ReSort = "NO"
For iterInputNum = 0 to ArrayCount
If iterInputNum < ArrayCount Then
If Cint(SplitInputNumbers(iterInputNum)) > Cint(SplitInputNumbers(iterInputNum+1)) Then
Num1 = SplitInputNumbers(iterInputNum)
Num2 = SplitInputNumbers(iterInputNum+1)
SplitInputNumbers(iterInputNum+1) = Num1
SplitInputNumbers(iterInputNum) = Num2
ReSort = "YES"
End If
End If
Next
Wend
'Code Ends Here
Thanks and Regards,
Swami