vba 范围类的自动过滤方法因标准而失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22941764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Auto filter method of range class failed with Criteria
提问by srt
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".
在第 2 行,我收到一条错误消息,提示“范围类的自动过滤方法失败”。
回答by Instant Breakfast
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"
):
您的问题在于您定义的范围。自动过滤器只希望引用标题行。如果您将其添加到您的代码中,它应该会按照您期望的方式工作(唯一的变化是在从K103
到的范围内K1"
):
rmdvsheet.Range("A1:K1").AutoFilter Field:=10, Criteria1:="D7u L462-L494 17MY"
回答by m.w
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
我有同样的问题。如果您转到正确的工作表并且没有其他语法错误。这是因为可能在原始工作表中,它已经被自动过滤了。如下图所示。要解决此问题,只需单击过滤按钮即可返回未过滤状态。 图片
回答by Gary's Student
Make sure you have the correct worksheet.
确保您有正确的工作表。
Make sure the data in the sheet cells have no double quotes. Like:
确保工作表单元格中的数据没有双引号。喜欢: