Sorting multiples sheets

andreascostas

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

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
13,575
Office Version
  1. 2007
Platform
  1. 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,141,204
Messages
5,704,956
Members
421,373
Latest member
dalziel079

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top