Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We have collected approx 100 pieces of info on 250 students, each held
student id being the column header and the data held in that column. We want to be able to select all the data and to be able to sort each column into ascending or descending order, independently of the other columns in a single opeation. (i.e. the equivalent of selecting each column of data, sorting it, then selecting the next etc., until all hav been slected and sorted). Can anyone suggest how this may be done, is there a VBA script out there that can do this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following does 4 columns and assumes the same number of rows in
each column. You can easily modify it to suit. Sub Macro1() Dim iEnd As Integer Dim ws As Worksheet Set ws = Sheets("Sheet1") iEnd = ws.Range("A1").End(xlDown).Row For iCol = 1 To 4 ws.Range(Cells(1, iCol), Cells(iEnd, iCol)).Sort Key1:=Cells(2, iCol), _ Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Next iCol End Sub Hth, Merjet |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks a lot for this, with a bit of fiddling I have managed to get it to do
just what I needed. Great and thanks once again "merjet" wrote: The following does 4 columns and assumes the same number of rows in each column. You can easily modify it to suit. Sub Macro1() Dim iEnd As Integer Dim ws As Worksheet Set ws = Sheets("Sheet1") iEnd = ws.Range("A1").End(xlDown).Row For iCol = 1 To 4 ws.Range(Cells(1, iCol), Cells(iEnd, iCol)).Sort Key1:=Cells(2, iCol), _ Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Next iCol End Sub Hth, Merjet |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple columns into single row | Excel Discussion (Misc queries) | |||
move multiple columns into single set of columns | Excel Discussion (Misc queries) | |||
removing single quotes from a paste operation | Excel Programming | |||
SUMIF with multiple criteria for multiple columns to sum a single | Excel Programming | |||
How do I lock columns together in a single row for sorting purpos. | Excel Discussion (Misc queries) |