Results 1 to 10 of 20

Thread: Just testing a before a possible Thread post. No reply needed

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    I am thinking of an alternative approach, the idea being to reduce on the steps to reorganising the array at every swap stage.. the idea came from 2 things …

    _1 The recursion routine is fed currently the row indices of the rows that need to be sorted.
    _2 We can use the VBA Application.Index Method allows us to re sort an array “ in one go “ via a code line like , pseudo formula..

    arrOut() = App.Indx( ArrIn() , {1;3;2} , {1,2,3} )
    arrOut() = App.Indx( ArrIn() , row indices , column indicies )

    The above code line would change an arrIn() like this …_
    A b c
    D e f
    G h I
    _ … to a given output in arrOut() like this:
    A b c
    G h I
    D e f

    So the idea is that we sort the indices values, and then re apply the formula above

    At this stage I propose modifying the existing code so as to have a better chance of a direct comparison in performance.. Both will be then subject to similar general inefficiencies arising from the very opened out explicit form of the codings generally

    Here the basic modifications for Sub SimpleArraySort7(__ , Sub TestieSimpleArraySort7()

    Global Variables
    To help simplify the comparison and so reduce the changes to the routines, I will have a couple of Global variables at the top of the module and outside any routine for the row and column indices
    Dim Cms() As Variant, Rs() As Variant
    This will allow me to refer to, that is to say change and use, in any copy of the recursion routine. (It would also be an alternative place here at the top of the module and outside any routine for our main array, arrTS(): we could then always refer to this, and then not need the ByRef arsRef() at the signature line of the recursion routine. But for now I will leave that as it is for closer comparison of the routines )
    To help in the development of this coding and to help with the explanation here, I have also moved the variable for the test range, RngToSort , to the top of the module and outside any routine to make it a global variable: This way I can use it’s dimensions to position intermediate paste outs of the arrTS(). For example , I have added a section immediately after the end of the main outer loop == for sorting, ' Captains Blog, Start Treck , which pastes out the current state of the sorted array , arrTS(), along with the current state of the indices, Rs()
    Code:
    ' Captains Blog, Start Treck
     Let RngToSort.Offset((RngToSort.Rows.Count * (CopyNo + 1)), 0).Value = arsRef()
     RngToSort.Offset((RngToSort.Rows.Count * (CopyNo + 1)), -1).Resize(UBound(Rs(), 1), UBound(Rs(), 2)).Value = Rs()
     Debug.Print " Running Copy " & CopyNo & " of routine." & vbCr & vbLf & "  Sorted rows " & strRws & " based on values in column " & Clm & vbCr & vbLf & "   Checking now for Dups in that last sorted list" & vbCr & vbLf
    For color=Blue]Sub[/color] SimpleArraySort7(__ I will also include a new array variable , as a global variable, arrIndx(). This I will fill by the formula line of
    arrIndx() = Application.Index(arrIndx(), Rs(), Cms())

    Modifying indices values in main sort loop sorting
    The way the current coding is organised this is fairly simple. We have sections where row elements are swapped. We use the row information in the variables rOuter and rInner. So quite simply, we do the same swap for row indices,


    Initial row indicees

    Evaluate(Row(1to15)).JPG : https://imgur.com/UVTQCYO


    Evaluate(Column(1to6)).JPG : https://imgur.com/jbaZdgJ
    Last edited by DocAElstein; 03-13-2019 at 02:07 PM.

Similar Threads

  1. Replies: 189
    Last Post: 02-06-2025, 02:53 PM
  2. Vlookup help needed
    By AbuReem in forum Excel Help
    Replies: 15
    Last Post: 11-12-2013, 11:32 AM
  3. TESTING Column Letter test Sort Last Row
    By alansidman in forum Test Area
    Replies: 0
    Last Post: 10-24-2013, 07:14 PM
  4. formulas needed please
    By paul_pearson in forum Excel Help
    Replies: 5
    Last Post: 03-21-2013, 04:43 PM
  5. Feed / Post Data on Web Page Using VBA
    By in.vaibhav in forum Excel Help
    Replies: 10
    Last Post: 01-10-2013, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •