过滤多个列/字段

时间:2017-04-25 07:08:04

标签: excel-vba autofilter vba excel

我有一张Excel表格,其中包含大约10列和数百行。我想在多列上应用过滤器,只有在满足两列条件时才显示数据。

一列有Team name,另一列有Team number。仅当Team name"项目" wkFilterTeam 变量和Team number中的值时,才会显示数据的"的Team2"

Function ProcessTeams(inTeamName As String) As Integer
     wkFilterTeam = inTeamName
     If (InStr(wkFilterTeam, "Markets") > 0) Then
         With Sheets("RawData")
            .AutoFilterMode = False
            Range("$A:$BG").AutoFilter
            Range("$A:$BG").AutoFilter FIELD:=3, 
            Criteria1:=Array(wkFilterTeam, "Projects"), Operator:=xlFilterValues
            Range("$A:$BG").AutoFilter FIELD:=4, Criteria1:=Array("Team2"), Operator:=xlFilterValues
         End With
     EndIf
End Function

但这显示了所有名为项目且团队编号为 Team2

的团队

0 个答案:

没有答案