#define xlAscending 1 #define xlGuess 0 #define xlTopToBottom 1 lnLastRow = oExcel.activesheet.UsedRange.Rows.Count oExcel.activesheet.Range("A1:G"+TRIM(PADR(lnLastRow,11))).select WITH oExcel.Selection .Sort(oExcel.Range("A1"), xlAscending,,,,,, xlGuess, 1, .f., xlTopToBottom) ENDWITH