Sorting multiples sheets

andreascostas

Board Regular
Joined
Jan 11, 2011
Messages
140
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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
8,790
Office Version
2007
Platform
Windows
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
 

Forum statistics

Threads
1,081,862
Messages
5,361,742
Members
400,653
Latest member
ProParadox

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top