excel vba隐藏过滤箭头?

时间:2015-06-23 13:16:50

标签: excel vba filter

我正在使用以下脚本根据单元格值过滤我的行。 该脚本工作正常,但我试图摆脱那些恼人的过滤箭头显示。我尝试了以下但他们仍然显示:

Sub DateFilter()
Dim nRow As Range
Dim toSearch As Range
    'hide dialogs
    Application.ScreenUpdating = False
    'filter for records that have June 11, 2012 in column 3


    If ActiveSheet.Range("B6").Value = "" And ActiveSheet.FilterMode = True Then
    ActiveSheet.ShowAllData
    Else
    Set toSearch = Range("A9:E13")
    'detect row that matches criteria:
    Set nRow = toSearch.Find(ActiveSheet.Range("B6").Value)
    If Not (nRow Is Nothing) Then
        ActiveSheet.Range("E9:A13").AutoFilter Field:=nRow.Column, VisibleDropDown:=False, Criteria1:="*" & nRow.Value & "*"
    End If
    End If
    Application.ScreenUpdating = True
End Sub

请有人告诉我我哪里出错了。提前谢谢

1 个答案:

答案 0 :(得分:0)

我知道这是一篇过时的文章,但是有人可以使用这段代码。

Range("A3:H3").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, VisibleDropDown:=False
Selection.AutoFilter Field:=7, VisibleDropDown:=False

这将为那些具有多个标题行的人添加“ A3:H3”中的过滤器下拉箭头。

然后它将删除第4列和第7列(D和G)中的下拉箭头,以便仅过滤的列为A-C,E-F和H。

希望这可以清除有关唯一过滤器的一些问题。