tag:blogger.com,1999:blog-28492262.post2497052039079603462..comments2023-12-27T22:22:25.151-08:00Comments on VBA Tips & Tricks: Create AutoFilter with Multiple Criteria using Excel VBAUnknownnoreply@blogger.comBlogger14125tag:blogger.com,1999:blog-28492262.post-14047853173007332492015-09-16T07:44:16.055-07:002015-09-16T07:44:16.055-07:00I'm having the same problemI'm having the same problemAnonymoushttps://www.blogger.com/profile/14395700689124187434noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-91104093547589291572013-07-26T11:15:48.233-07:002013-07-26T11:15:48.233-07:00Still does not work keeps on returning the last va...Still does not work keeps on returning the last value of the array example: always and only "Grape"VBAhttps://www.blogger.com/profile/18166030929085142663noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-39588199851180721102013-02-07T01:24:33.572-08:002013-02-07T01:24:33.572-08:00Correct code, without syntax errors (at least with...Correct code, without syntax errors (at least with Excel 2k13). IMO xlFilterValues + Criteria1 Array is the best option<br /><br />Nice blog. Keep going, I use to get here almost everytime I wonder how to do on VBA...<br /><br />Sub AutoFilter_WithMultiple_Criteria()<br /> Dim oWS As Excel.Worksheet<br /> Dim intField As Integer<br /> <br /> On Error GoTo Err_Filter<br /> Set oWS = ActiveSheet<br /> <br />'!!!!!<br /> intField = 2<br />'!!!!!<br /> oWS.UsedRange.AutoFilter Field:=intField, Criteria1:=Array("Apple", "Orange", "Grape"), _<br /> Operator:=XlAutoFilterOperator.xlFilterValues '.xlAnd '.xlOr<br /><br />Finally:<br /> If Not oWS Is Nothing Then _<br /> Set oWS = Nothing<br /> On Error GoTo 0<br /><br />Err_Filter:<br /> If Err <> 0 Then<br /> MsgBox (Err.Description)<br /> Err.Clear '()<br /> GoTo Finally<br /> End If<br /><br />End Sub<br /><br />enrique.luengo.corbalhttps://www.blogger.com/profile/03482412303776348846noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-20716787203622515642013-01-10T04:19:16.898-08:002013-01-10T04:19:16.898-08:00Except it doesn't work. It returns the last va...Except it doesn't work. It returns the last value from array in filtered data - "3".Anonymoushttps://www.blogger.com/profile/14519271447887303439noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-88867970371649505442012-08-04T09:25:32.467-07:002012-08-04T09:25:32.467-07:00rngData.AutoFilter Field:=1, Criteria1:=array(&quo...rngData.AutoFilter Field:=1, Criteria1:=array("1","2","3"), Operator:=xlFilterValues<br /><br />this is the best solution<br /><br />thnks<br />rjAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-28492262.post-78451436790136566582012-03-02T02:28:31.954-08:002012-03-02T02:28:31.954-08:00Swaroop : Try this syntax
ActiveSheet.UsedRange....Swaroop : Try this syntax <br /><br />ActiveSheet.UsedRange.AutoFilter Field:=2, Criteria1:="Apple", Operator:=XlAutoFilterOperator.xlOr, Criteria2:="Orange"Swaroop Vennahttps://www.blogger.com/profile/08640222892421980276noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-40510546135383838712012-02-22T10:16:13.803-08:002012-02-22T10:16:13.803-08:00You can use an array as criteria1 with xlFilterVal...You can use an array as criteria1 with xlFilterValues as the operator.<br /><br /><br />rngData.AutoFilter Field:=1, Criteria1:=array("1","2","3"), Operator:=xlFilterValuesAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-28492262.post-35246630676495143272011-12-18T17:42:08.302-08:002011-12-18T17:42:08.302-08:00Excel autofilter function only allows 1 or 2 crite...Excel autofilter function only allows 1 or 2 criteria. If you want more, you have to create a custom function to duplicate what autofilter does (compares criteria and then hides rows that don't match)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-28492262.post-16281259206538126732011-10-27T03:56:03.062-07:002011-10-27T03:56:03.062-07:00I am using similar coding but I have 1 filter on c...I am using similar coding but I have 1 filter on column 1 and need to apply 3 "or" filters to column 2. It can cope with the initial filter on column 1 and 2 "or" filters on column 2 but when I add a 3rd filter to column 2 it gives me the application or object defined error.<br /><br />AutoFilter(Field:=1, Criteria1:="1", Operator:=XlAutoFilterOperator.xlOr, Criteria2:="Orange",Operator:=XlAutoFilterOperator.xlOr,Criteria3:="Peach" ) <br /><br />If I comment out the 3rd operator and criteria, it works fine. Is there a limit to the number of criteria you can filter? All of the examples I have found online only have 2 criteriaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-28492262.post-22453494264486172382009-11-14T17:56:12.161-08:002009-11-14T17:56:12.161-08:00Hi can i get VB script for below example,it should...Hi can i get VB script for below example,it should select Active=testing into one another excel sheet,Active=integration into another excel sheet and remaining all ="active" except testing & Designing into another excel sheet<br /><br />1 shankar Active Testing<br />2 Venkat Terminated Intrgration<br />3 shilpa Active Designing<br />4 Mohan Active Testing<br />5 bindhu Active Designing<br />6 Sunny Terminated testingAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-28492262.post-65762380959854562042009-09-05T19:45:37.737-07:002009-09-05T19:45:37.737-07:00Which version of Excel are you using? Can you plea...Which version of Excel are you using? Can you please elaborate on the error it throws if possible?M Shasurhttps://www.blogger.com/profile/17390752937266096344noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-46244292810218863482009-09-05T18:43:22.470-07:002009-09-05T18:43:22.470-07:00i keep getting -
compile error syntax error ?
o...i keep getting - <br />compile error syntax error ? <br /><br />oWS.UsedRange.AutoFilter(Field:=1, Criteria1:="1", Operator:=XlAutoFilterOperator.xlOr, Criteria2:="Orange")Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-28492262.post-79954897143078570342009-06-04T07:15:49.774-07:002009-06-04T07:15:49.774-07:00What you mean multiple?
this can be already seen r...What you mean multiple?<br />this can be already seen recording macro. :(ziusudrahttps://www.blogger.com/profile/02460308004953846056noreply@blogger.comtag:blogger.com,1999:blog-28492262.post-64696383811912652962009-04-24T03:17:00.000-07:002009-04-24T03:17:00.000-07:00That's only two criteria, not multipleThat's only two criteria, not multipleUnknownhttps://www.blogger.com/profile/16622104491769029422noreply@blogger.com