[英]AutoFilter in Macro does only apply when I go into Excel after running it open the filter options and click ok
I am trying to filter out all Data where my used VLookup doesn't find a value so, in the German version this means that in these columns is writen #NV.我试图过滤掉我使用的 VLookup 找不到值的所有数据,因此,在德语版本中,这意味着在这些列中写入#NV。 I tried to do this by using an AutoFilter that shows all data not equaling #NV.
我试图通过使用显示所有不等于#NV 的数据的自动过滤器来做到这一点。 After running the macro the filter is applied but the data is not filtered, I have to go into the sheet open the filter options and press ok then the filter is applied.
运行宏后应用过滤器但未过滤数据,我必须将 go 放入工作表打开过滤器选项并按确定然后应用过滤器。 My code for the Filter is:
我的过滤器代码是:
ActiveSheet.ShowAllData
ActiveSheet.range("A:C").AutoFilter Field:=3, Criteria1:="<>#NV", Operator:=xlAnd
ActiveSheet.AutoFilter.ApplyFilter
After running the macro with the code above before pressing ok在按确定之前使用上面的代码运行宏之后
What is also weird I also filter for Data equaling #NV in the same Macro there the filter works just fine.同样奇怪的是,我还在同一个宏中过滤了等于#NV 的数据,过滤器工作得很好。 Here is my code for that part:
这是我的那部分代码:
ActiveSheet.range("A:C").AutoFilter Field:=3, Criteria1:="#NV", Operator:=xlAnd
It looks like the filter function is not working like expected.看起来过滤器 function 没有按预期工作。
If yo use Criteria1:="<>#N/A"
- the result seems to be ok.如果您使用
Criteria1:="<>#N/A"
- 结果似乎没问题。
But maybe you want to avoid NA at all.但也许您想完全避免使用 NA。 You can achieve this by using
=IFNA(
together with your VLOOKUP
- applying a value that fits your needs and that can be filtered without problems (in German: WENNNV(
)您可以通过将
=IFNA(
与您的VLOOKUP
一起使用来实现这一点 - 应用适合您需要的值并且可以毫无问题地进行过滤(德语: WENNNV(
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.