过滤数字字段 [英] Filter numeric field

查看:149
本文介绍了过滤数字字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

  ActiveSheet.Range($ A $ 1:$ P $ 201)。AutoFilter Field := 5,Criteria1:== 10* 

当我点击过滤器并输入搜索栏 10 * 我得到所有以 10 开头的结果。当使用宏,这是行不通的。目标是让宏使用我提供的前两个数字进行过滤。



你能协助吗?

解决方案

尝试将文本过滤器应用于数字字段。
而不是:

  ActiveSheet.Range($ A $ 1:$ P $ 201)。AutoFilter Field:= 5 ActiveSheet.Range($ A $ 1:$ P $ 201)。AutoFilter Field:= 5,Criteria1:== 10* 

只是:
$ b $ pre $ ActiveSheet.Range($ A $ 1:$ P $ 201)。 AutoFilter字段:= 5,_
Criteria1:=> = 10000,Operator:= xlAnd,Criteria2:=<= 10999

似乎已经工作了。


I have the following code:

ActiveSheet.Range("$A$1:$P$201").AutoFilter Field:=5, Criteria1:="=10"* 

When I click on the filter and type in the search bar 10* I get all results that start with 10. When using the macro, that doesn't work. The goal is for the macro to filter using the first two numbers provided by me.

Can you assist?

解决方案

The core of the problem seems to have been trying to apply a text filter to a numeric field. Instead of:

ActiveSheet.Range("$A$1:$P$201").AutoFilter Field:=5 ActiveSheet.Range("$A$1:$P$201").AutoFilter Field:=5, Criteria1:="=10"*

just:

ActiveSheet.Range("$A$1:$P$201").AutoFilter Field:=5, _  
    Criteria1:=">=10000", Operator:=xlAnd, Criteria2:="<=10999"

seems to have worked.

这篇关于过滤数字字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆