隐藏自动过滤器箭头不起作用 [英] Hiding autofilter arrows not working

查看:34
本文介绍了隐藏自动过滤器箭头不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'data is filtered
Sub Filtration(mainsheet As Worksheet, lastrow As Long)

    Application.ScreenUpdating = False

    With mainsheet

        'filters
        .Range("$A$12:$J$" & lastrow).AutoFilter Field:=7, Criteria1:="TRUE" 
        .Range("$A$12:$J$" & lastrow).AutoFilter Field:=10, Criteria1:="TRUE"

        HideAutoFilterDropdowns

    End With

    Application.ScreenUpdating = True

End Sub

Sub HideAutoFilterDropdowns()
    With Range("A12")
        .AutoFilter Field:=1, VisibleDropDown:=False
        .AutoFilter Field:=2, VisibleDropDown:=False
        .AutoFilter Field:=3, VisibleDropDown:=False
        .AutoFilter Field:=4, VisibleDropDown:=False
        .AutoFilter Field:=5, VisibleDropDown:=False
        .AutoFilter Field:=6, VisibleDropDown:=False
        .AutoFilter Field:=7, VisibleDropDown:=False 'problem is here
        .AutoFilter Field:=8, VisibleDropDown:=False
        .AutoFilter Field:=9, VisibleDropDown:=False
        .AutoFilter Field:=10, VisibleDropDown:=False
    End With
End Sub

上面的代码中发生的事情是我的工作表上有一组数据,并按字段号7和10(G和J列)进行了过滤.然后,我想隐藏下拉箭头.适用于1-6&8-10,但是当我尝试隐藏第7列,以取消过滤数据(与Filtration函数的功能相反).

What happens in the code above is I have a set of data on my sheet and it is filtered by field number 7 and 10 (column G & J). I then want to hide the drop down arrows. It works for 1-6 & 8-10, but when I try to hide column 7 it unfilters the data (counter to what the Filtration function did).

推荐答案

您需要在行中保留 Criteria1:= 代码.删除该条件并运行 HideAutoFilterDropdowns()后,实际上是在告诉它删除条件过滤器.

You need to leave your Criteria1:= code in the line. Once you remove that Criteria and run HideAutoFilterDropdowns() you are actually telling it to remove the Criteria filter.

With mainsheet

    'filters
    .Range("$A$12:$J$" & lastrow).AutoFilter Field:=7, Criteria1:="TRUE", VisibleDropDown:=False 
    .Range("$A$12:$J$" & lastrow).AutoFilter Field:=10, Criteria1:="TRUE", VisibleDropDown:=False

End With

这篇关于隐藏自动过滤器箭头不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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