this will open an EXCEL workbook, sort the columns, and close the document (currently does not save changes)
Add a reference to Microsoft Excel x.0 Object Library
Enjoy!Code:Dim xl As Excel.Application Dim wb As Excel.Workbook Set xl = New Excel.Application Set wb = xl.Workbooks.Open("C:\test4.xls") With wb.Application .Columns("B:B").Select .Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom .Columns("C:C").Select .Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End With wb.Close False xl.Quit Set xl = Nothing
Tom




Reply With Quote