问题
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