lnLastRow = oExcel.activesheet.UsedRange.Rows.Count oExcel.activesheet.Range("A1:G"+TRIM(PADR(lnLastRow,11))).select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom