ericbailey2 Posted January 28, 2008 Share Posted January 28, 2008 Awhile back I had assistance with a script using the ExcelCOM_UDF Basically it opens up a specified excel sheet, selects a specific row, then applies the autofilter to that row. I was wondering if it would be possible to expand this further and have it filter for certain criteria. For example, in column 3 there is a heading called Cities. How can I filter to only display "Los Angeles" or something of the like? CODE; Open the workbook, select first row, apply AutoFilter $oExcel = ObjCreate("Excel.Application") With $oExcel .Visible = True ; False if you don't want Excel visible .WorkBooks.Open("C:\File.XLS") .ActiveWorkbook.Sheets(1).Rows(4).Select() .Selection.AutoFilter; Once, to set the filter EndWith Link to comment Share on other sites More sharing options...
junkew Posted January 28, 2008 Share Posted January 28, 2008 Most likely something like Selection.AutoFilter(Field:=3, Criteria1:="los angeles") FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 28, 2008 Share Posted January 28, 2008 Most likely something likeSelection.AutoFilter(Field:=3, Criteria1:="los angeles")I don't know if that is one or two string parameters being passed, but I think it would either be:Selection.AutoFilter('Field:=3, Criteria1:="los angeles"') ; one parameter string-- or --Selection.AutoFilter('Field:=3', 'Criteria1:="los angeles"') ; two parameter strings Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ericbailey2 Posted January 28, 2008 Author Share Posted January 28, 2008 I don't know if that is one or two string parameters being passed, but I think it would either be:Selection.AutoFilter('Field:=3, Criteria1:="los angeles"') ; one parameter string-- or --Selection.AutoFilter('Field:=3', 'Criteria1:="los angeles"') ; two parameter strings I tried both, its giving me the following error:>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Script.au3" C:\Script.au3 (9) : ==> The requested action with this object has failed.: .Selection.AutoFilter('Field:=3', 'Criteria1:="Los Angeles"') .Selection.AutoFilter('Field:=3', 'Criteria1:="Los Angeles"')^ ERROR>Exit code: 1 Time: 0.917I even tried changing a few things around. Still no go. Link to comment Share on other sites More sharing options...
ericbailey2 Posted January 29, 2008 Author Share Posted January 29, 2008 I tried a few other things, I believe their is a way, I just think that the syntax is wrong. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 30, 2008 Moderators Share Posted January 30, 2008 Try this: Selection.AutoFilter(3, "los angeles") Link to comment Share on other sites More sharing options...
ericbailey2 Posted January 30, 2008 Author Share Posted January 30, 2008 I think were getting closer, this time it ran without giving me an error, but it didn't filter. Link to comment Share on other sites More sharing options...
ericbailey2 Posted January 30, 2008 Author Share Posted January 30, 2008 Nevermind, I had to add an extra .Selection.AutoFilter line above the one you gave me. Thank you very much Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 30, 2008 Moderators Share Posted January 30, 2008 You're welcome, glad I was able to help. 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