nirious Posted April 14, 2014 Share Posted April 14, 2014 Columns("A:M").Select ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("M2:M809") _ , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet1").Sort .SetRange Range("A1:M809") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Hi, I can't get this vba code that I got from an excel macro to work with autoit. Link to comment Share on other sites More sharing options...
FireFox Posted April 14, 2014 Share Posted April 14, 2014 Hi, Welcome to the autoit forum Can you show us what you've tried so far ? Or you expect us to do it for you ? Br, FireFox. Link to comment Share on other sites More sharing options...
water Posted April 14, 2014 Share Posted April 14, 2014 Please have a look at the latest AutoIt beta version (3.3.11.4). it comes with a sort function (_Excel_RangeSort) that should do what you need. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
nirious Posted April 14, 2014 Author Share Posted April 14, 2014 Thank you for the kind welcome. I need to automate some actions on an excel file outside of excel. So I came across autoit Everything seems to be kind of straight foreward but I was struggeling to transform that := property notation to something that is accepted by autoit. I need to keep the header of a file and sort all other rows based on column M. This is what I had so far (part of it is commented out ) treating the := as a property treating the whole thing as a single string with or without () $exlYes=1 $exlTopToBottom=1 $exlPinYin=1 $exlSortOnValues=0 $exlAscending=1 $exlSortNormal=0 $exlSortColumns=1 ;$oExcel1.ActiveSheet.Columns("A:M").Select ;$oExcel1.ActiveSheet.Sort.SortFields.Clear ;$oExcel1.ActiveSheet.Sort.SortFields.Add('Key:=Range("M2:M"' & $iLastLineNr & '), SortOn:=' & $xlSortOnValues & ', Order:=' & $xlAscending & ', DataOption:=' & $xlSortNormal) ;$oExcel1.ActiveSheet.Sort.SetRange($oExcel1.ActiveSheet.Range("A1:M" & $iLastLineNr)) ;$oExcel1.ActiveSheet.Sort.Header = $exlYes ;$oExcel1.ActiveSheet.Sort.MatchCase = False ;$oExcel1.ActiveSheet.Sort.Orientation = $exlTopToBottom ;$oExcel1.ActiveSheet.Sort.SortMethod = $exlPinYin ;$oExcel1.ActiveSheet.Sort.Apply Though I finally managed to get it working by extending a piece of code I found via google and figuring out how to put in the unused properties in the function. It has a totally different approach, but the end result is the same. $oExcel1.ActiveSheet.Range("M1").Sort($oExcel1.ActiveSheet.Range("M:M"), $exlAscending, Null, Null, $exlAscending, Null, $exlAscending, $exlYes, Null, False, $exlSortColumns, $exlPinYin, $exlSortNormal, $exlSortNormal, $exlSortNormal) I wasn't aware of the _Excel_RangeSort function. Though I still would like to know what the autoit alternative is for the vba := notation. Link to comment Share on other sites More sharing options...
water Posted April 14, 2014 Share Posted April 14, 2014 Though I still would like to know what the autoit alternative is for the vba := notation. AutoIt doesn't support named parameters. "Key" is the first parameter in the parameter list. So simply drop the "Key:=" part and only add the value of the parameter e.g. Range("M2:M809") Replace parameters you don't know with the "Default" keyword. Details can be found here. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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