Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default rearrange an array in a different order


Tom, what is you SwapTwo code? Thanks!


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
rearrange cells in random order Amy B Excel Discussion (Misc queries) 1 April 20th 09 02:08 AM
Rearrange numbers from a column in a different order in a second c Gaetan58 Excel Discussion (Misc queries) 14 November 21st 06 07:43 AM
can i rearrange names in alphabetic order... naughtyboy Excel Discussion (Misc queries) 2 August 7th 06 09:50 AM
How do I rearrange the worksheet name order in the windows menu? Brad Excel Discussion (Misc queries) 0 September 21st 05 08:30 PM
How to rearrange order based on dates of inputs? FISH Charts and Charting in Excel 2 September 21st 05 01:06 PM


All times are GMT +1. The time now is 02:17 PM.

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

About Us

"It's about Microsoft Excel"