想自己做一个筛选窗口,希望显示出符合筛选条件的单元格所在的行,认为空的单元格是符合条件的。
我写的筛选代码是这样的:
DataTables("b1").Save()
Dim Filter1 As String
With e.Form.Controls("TextBox1")
If .Value IsNot Nothing Then
Filter1 = "a1 <= '" & .Value & "' or a1 is null"
End If
End With
With e.Form.Controls("TextBox1")
If .Value IsNot Nothing Then
If Filter1 >"" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "a21 >= '" & .Value & "' or a21 is null"
End If
End With
With e.Form.Controls("TextBox2")
If .Value IsNot Nothing Then
If Filter1 >"" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "a11 >= '" & .Value & "' or a11 is null"
End If
End With
With e.Form.Controls("ComboBox6")
If .Value IsNot Nothing Then
If Filter1 >"" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "a17 like '%" & .Value & "%' or a17 is null"
End If
End With
If Filter1 > "" Then
Tables("a1").Filter = Filter1
End If
但是这个的效果是如果筛选了两个或两个以上的条件就会显示所有的筛选列中空单元格所在行,即便这行里有单元格里的内容是不符合其他筛选条件的。
我希望可以达到筛选之后显示满足所有筛选条件的行,请问该如何修改?