HighlanderSword Posted October 11, 2011 Share Posted October 11, 2011 (edited) Hello, I need to do a sort with an excel file, listed below is the code I'mm using , I took this from a recorded macro in Excel. I made modfications to it to reference the $Oexcel_to Variable that I'm using. When I try and run this it fails on the line $oExcel_to.ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key=Range("A:A"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal At the Add Key part of the string stating that their is a syntax error. Any Ideas what I'm missing ? #include <String.au3> #include <Excel.au3> #include <Array.au3> #include <date.au3> $oExcel_to=_ExcelBookOpen("c:\test1.xlsx",1) $oExcel_to.Cells.Select $oExcel_to.ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear $oExcel_to.ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key=Range("A:A"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With $oExcel_to.ActiveWorkbook.Worksheets("Sheet1").Sort .SetRange Range("A:A") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Edited October 11, 2011 by HighlanderSword Link to comment Share on other sites More sharing options...
HighlanderSword Posted October 11, 2011 Author Share Posted October 11, 2011 Hello All, I was able to figure it out, I ended up using the line bwlow toaddress my sort requirement $oExcel_to.range("A1").sort ($oExcel_to.range ("A:A")) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now