Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
rearrange an array in a different order
I have this array myarray(3) with these values: myarray(1)="Y" myarray(2)="Other" myarray(3)="N" Now I need to have the array in the following order: myarray(1)="N" myarray(2)="Y" myarray(3)="Other" What's the code for that? Thanks -- ~~ Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
rearrange an array in a different order
"clui" wrote in message ... I have this array myarray(3) with these values: myarray(1)="Y" myarray(2)="Other" myarray(3)="N"Sub Main() Dim myArray(1 To 3) myArray(1) = "Y" myArray(2) = "Other" myArray(3) = "N" SwapTwo myArray(3), myArray(2) SwapTwo myArray(1), myArray(2) For i = 1 To 3 Debug.Print "myarray(" & i & ") = " & myArray(i) Next End Sub produces: myarray(1) = N myarray(2) = Y myarray(3) = Other -- Regards, Tom Ogilvy Now I need to have the array in the following order: myarray(1)="N" myarray(2)="Y" myarray(3)="Other" What's the code for that? Thanks! --- ~~ Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
rearrange an array in a different order
|
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
rearrange an array in a different order
Well that got all jumbled up:
Sub SwapTwo( item1, item2 ) Dim temp as Variant temp = item1 item1 = item2 item2 = temp End Sub Sub Main() Dim myArray(1 To 3) myArray(1) = "Y" myArray(2) = "Other" myArray(3) = "N" SwapTwo myArray(3), myArray(2) SwapTwo myArray(1), myArray(2) For i = 1 To 3 Debug.Print "myarray(" & i & ") = " & myArray(i) Next End Sub -- Regards, Tom Ogilvy clui wrote in message ... Tom, what is you SwapTwo code? Thanks! --- ~~ Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
rearrange cells in random order | Excel Discussion (Misc queries) | |||
Rearrange numbers from a column in a different order in a second c | Excel Discussion (Misc queries) | |||
can i rearrange names in alphabetic order... | Excel Discussion (Misc queries) | |||
How do I rearrange the worksheet name order in the windows menu? | Excel Discussion (Misc queries) | |||
How to rearrange order based on dates of inputs? | Charts and Charting in Excel |