• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

order multiple dependent arrays

Edcronos

Member
Code:
ci1 = 1
    inC = ci1:
    i = inC + 1
    Do
        A = array2(inC, 1)
        b = array2(inC + 1, 1)
        Aa = array1(inC, 1)
        ba = array1(inC + 1, 1)
        If A > b Then
            array2(inC, 1) = b: c = A
            array2(inC + 1, 1) = c
            array1(inC, 1) = ba: ca = Aa
            array1(inC + 1, 1) = ca
            If inC > ci1 Then inC = inC - 1
        Else
            inC = i: i = i + 1
        End If
    Loop Until inC = lf

order multiple dependent arrays
as you can see by the macro I used compared on a drive and the values in two arrays

but what if they were several arrays?
the variables A, B, C could be arrays with the number of elements in the arrays amount of
but it would not help much
how to not get something implaticavel?
 
What you could do is add all the arrays together into a single array
As you do that add a new field which holds the source arrays name
Then do the sort
Then rewrite each array
 
I even imagine something like
It is to show an example?
as are multi dimensional arrays, I am unsure how to do and want to do the same thing by ordering the columns, which is my greatest interest
 
I looked at the page and the information about the arrays were of great value

but I found it a little tricky to what I want
perhaps a macro, which sweep the main array, save the position that each element has to stay another arrayB
and from that arrayB order all other
 
Does this logic is correct?

Code:
Sub testdd()    'ByRef Array1, ByVal Coluna_referencia As Long)
    Dim arrayL() As Long, va As String, Array1()
    Array1 = Range("A1:c10").Value2
    Lft = UBound(Array1, 1)
    ReDim arrayL(1 To Lft)
    For L = 1 To Lft
        arrayL(L) = L
    Next

    Cx = 2    'Coluna_referencia


    ci1 = 1
    inC = ci1:
    i = inC + 1
    Do
        A = Array1(inC, Cx)
        b = Array1(inC + 1, Cx)
        Aa = arrayL(inC)
        ba = arrayL(inC + 1)

        If A > b Then
            Array1(inC, Cx) = b: c = A
            Array1(inC + 1, Cx) = c
            arrayL(inC) = ba: ca = Aa
            arrayL(inC + 1) = ca
            If inC > ci1 Then inC = inC - 1
        Else
            inC = i: i = i + 1
        End If
    Loop Until inC = Lft

    For c = 1 To UBound(Array1, 2)
        If c <> Cx Then
            'A = Array1(1, c)
            'b = arrayL(1)
            For L = 1 To Lft
                Array1(L, c) = Array1(arrayL(L), c)
            Next
        End If
    Next

    Range("A1:c10").Value2 = Array1
End Sub
 
Last edited:
yeah, it's almost correct only
just work from one array to another

thereby have to see a way the values are not overwritten
 
Back
Top