Results 1 to 4 of 4

Thread: Sorting multiples sheets
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jan 2011
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Sorting multiples sheets

    I have multiple sheets with student score data in cells C1:AP9
    No headers
    sort from left to right using row 9.
    Largest to smallest
    I tried using a macro with no luck. Any ideas or a VBA???
    Thanks

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    4,582
    Post Thanks / Like
    Mentioned
    42 Post(s)
    Tagged
    12 Thread(s)

    Default Re: Sorting multiples sheets

    Quote Originally Posted by andreascostas View Post
    I have multiple sheets with student score data in cells C1:AP9
    No headers
    sort from left to right using row 9.
    Largest to smallest
    I tried using a macro with no luck. Any ideas or a VBA???
    Thanks
    Use this, the macro temporarily uses the cells "C16:AP24" to sort the data.
    Try a sheet and tell me, if it's what you need, we do it for all the sheets.

    Code:
    Dim vals As New Collection
    Dim cols As New Collection
    
    
    Sub ordenar()
        Application.ScreenUpdating = False
        For j = Columns("C").Column To Columns("AP").Column
            Call agregar(Cells(9, j), j)
        Next
        '
        For i = 1 To cols.Count
            c = cols(i)
            Range(Cells(1, c), Cells(9, c)).Copy Cells(16, i + 2)
        Next
        
        Range(Cells(16, "C"), Cells(24, "AP")).Copy Range("C1")
        Range(Cells(16, "C"), Cells(24, "AP")).ClearContents
        
        Set vals = Nothing
        Set cols = Nothing
    End Sub
    
    
    Sub agregar(valor, col)
        For i = 1 To vals.Count
            If valor > vals(i) Then
                vals.Add valor, Before:=i
                cols.Add col, Before:=i
                Exit Sub
            End If
        Next
        vals.Add valor
        cols.Add col
    End Sub
    Regards Dante Amor

  3. #3
    Board Regular
    Join Date
    Jan 2011
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sorting multiples sheets

    Yes, it worked!!!

  4. #4
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    4,582
    Post Thanks / Like
    Mentioned
    42 Post(s)
    Tagged
    12 Thread(s)

    Default Re: Sorting multiples sheets

    Quote Originally Posted by andreascostas View Post
    Yes, it worked!!!
    I'm glad to help you. Thanks for the feedback.
    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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