对于多个条件,使用自动过滤器功能 [英] Using an Autofilter function for multiple criteria with cases

查看:103
本文介绍了对于多个条件,使用自动过滤器功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表,我想过滤T和U列中的空白行。



我有某些情况需要考虑。



我有几个缺少的行,并将它们表示为在列S中丢失。如果它们丢失,我不希望他们被考虑用于过滤条件。默认为空白。



另一种情况是,列T和U中的任何一行都被找到空白,必须被过滤。如果两列都为空,也必须进行过滤。



我附上了一张图片供参考。有人可以建议我怎么做吗我是VBA的初学者,任何一个领导都是有帮助的。

  Sub FC()
Dim ws As Worksheet

设置ws = FC)

与ws
.Range(A5:T1000)。autofilter字段:= 20,Criteria1:==,运算符:= xlFilterValues
结束与
End Sub

我尝试了上面的代码,它与列T一起使用。
我如何包括多个条件。因为我的情况下,列S丢失,我不需要考虑完整的行。和我的T和U,空白或任何一个是空白,然后我需要他们被过滤。





< a href =https://i.stack.imgur.com/QpLOG.png =nofollow noreferrer>![我想要一个代码,以这样一种方式,我想过滤列T和S与空行。列T和U中的任何行都找到空白,
然后我想过滤它们。] 2

解决方案

好的,所以这里是如何实现您的自定义过滤使用辅助列。让我们来看看这个任务的列 Z

  Sub FC()
with Sheets(FC)。Range(Z5:Z100)
.EntireColumn.Hidden = True'< - 可选,隐藏temp列
.Formula == AND(S5Missing,OR(ISBLANK(T5),ISBLANK(U5)))
.AutoFilter 1,True
End With
End Sub


I have an sheet, where i would like to filter the blank rows in column T and U.

I have certain cases to be considered.

I have few missing rows and have denoted them as missing in column S. If they are missing, I dont want them to be considered for filter condition. In Default they are blank.

The other case is, any one of the rows in column T and U are found blank, has to be filtered. IF both the column are blank also have to be filtered.

I have attached an Image for reference. Could anyone suggest me how I could do it ? I am a beginner in VBA ,Any lead would be helpful.

Sub FC()
Dim ws As Worksheet

Set ws = Sheets("FC")

With ws
.Range("A5:T1000").autofilter Field:=20, Criteria1:="=", Operator:=xlFilterValues
End With
End Sub

I tried the above code, It works with column T. How can i include multiple criteria. because with my cases, with column S as missing, I dont Need to consider the complete row. and with my T and U, both blank or any one is blank, then i Need them to be filtered.

![I would like to have a code, in such a way that, I want to filter the column T and S with blank rows. any of the rows in column T and U are found blank, then I would like to filter them.]2

解决方案

Ok so here's how you can achieve your custom filtering using a helper column. Let's take column Z for this mission.

Sub FC()
  With Sheets("FC").Range("Z5:Z100")
    .EntireColumn.Hidden = True  ' <-- optional, to hide the temp column
    .Formula = "=AND(S5<>""Missing"",OR(ISBLANK(T5),ISBLANK(U5)))"
    .AutoFilter 1, True
  End With
End Sub

这篇关于对于多个条件,使用自动过滤器功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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