Auto sorting
"Freshman" wrote in message
...
Dear all,
I've a table of records. Each record is filled in the spreadsheet by a
macro
automatically. Column B is for the "Department's name" and column E is for
the "input date". When each record is filled along the rows, the
department
name is not in order. Please advise how to sort the department name in
ascending order automatically and subject to the input date (records with
earlier date come first) whenever a new record is entered?
If record "writing" is handled by a macro, you just need a little extra code
at the end of the existing to handle the autosort.
Assuming you have labels in A1:E1, try:
Range("A1").CurrentRegion.Sort Key1:=Range("B2"), Order1:=xlAscending,
Key2:=Range("E2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom
|