Welcome !
         

 Multidimensional array sorting help required

Author Message
martho45

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 12/11/2016
  • Status: offline
Multidimensional array sorting help required Tuesday, December 13, 2016 9:10 AM (permalink)
0
Hi & thanks in advance for helping.
After a long time using Perl I am finding it difficult to get my head around what I need to do using VBScript in order to sort my data, I basically want to take an input from one sheet and sort the rows in another but it is the sorting I am struggling with. I have read quite a number of articles and it seems everyone has a different way of doing it.
 
so I have read my data and added it to a multi-dimensional array as such (dimesnion1=row number, dimension2=column number) - I can have 1-n rows but only 4 columns.
arr(rwArr, 1) = string
arr(rwArr, 2) = integer1
arr(rwArr, 3) = integer2
arr(rwArr, 4) = integer3
 
what I want to do is sort the array ascending based upon the value of integer1, if 2 rows have the same integer1 value then the order is judged on the value of integer2, if that does not break the deadlock then onto integer3 and so on (I will expand this to further checks, i.e. integer4... but will deal with that later). Once the order is sorted I want to write the output as string, integer1 on a new worksheet.
 
I hope someone has an easy answer & I am prepared to work on the code if I can be given a steer on how best to proceed.
 
thanks, Mark.
 
 
#1
    59cobalt

    • Total Posts : 2584
    • Scores: 253
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:Multidimensional array sorting help required Wednesday, December 14, 2016 1:14 PM (permalink)
    0
    You may want to load the data into a disconnected recordset rather than a 2-dimensional array.
     
    #2
      martho45

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 12/11/2016
      • Status: offline
      Re:Multidimensional array sorting help required Wednesday, December 14, 2016 8:09 PM (permalink)
      0
      thanks for the reply but the answer for me was much easier than I thought, new to me but I learned about recording macros and once I sorted the data in Excel I could easily read the macro and adapt the VBScript accordingly. I now have the macro sorting the data as I want.
       
      thanks again.
       
      #3
        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2017 ASPPlayground.NET Forum Version 3.9