Auto filter method of range class failed with Criteria

浪子不回头ぞ 提交于 2020-02-21 07:25:32

问题


Set rmdvsheet = ActiveWorkbook.Sheets(11)

    rmdvsheet.Range("A1:K103").AutoFilter Field:=10, Criteria1:= _
        "D7u L462-L494 17MY"

Here on 2nd line i am geting an error saying "Auto filter method of range class failed".


回答1:


Your problem is with the range you've defined. The autofilter only wants referral to the header row. If you sub this into your code, it should work the way you expect (the only change is in the range from K103 to K1"):

rmdvsheet.Range("A1:K1").AutoFilter Field:=10, Criteria1:="D7u L462-L494 17MY"



回答2:


Make sure you have the correct worksheet.

Make sure the data in the sheet cells have no double quotes. Like:




回答3:


I had the same problem. If you are turned to the right sheet and no other syntax error. It's because maybe in the original sheet, it is already autofiltered. Like in the following picture. To solve this, just click the filter button to return to the unfilter status. image



来源:https://stackoverflow.com/questions/22941764/auto-filter-method-of-range-class-failed-with-criteria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!