ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索

在保护的工作表上使用自动筛选功能

已有 1944 次阅读2008-8-25 15:33 |个人分类:原创

在保护工作表对话框中,提供了允许“使用自动筛选”的功能。相应的在保护工作表的Protect方法中,也存在一个对应的AllowFiltering参数。

Protect(Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables)

       但是事实上,如果需要在保护的工作表上使用自动筛选功能,需保证工作表处于自功筛选模式(必须先在工作表中显示自动筛选下拉箭头)。

以下代码允许在保护工作表后使用自动筛选功能。

Sub ProtectWithFiltering()
        With ActiveSheet
                If .AutoFilterMode = False Then   '如果工作表不处于自动筛选模式
                        .Range("A1").AutoFilter            '在指定区域切换自动筛选下拉箭头
                End If
               .Protect AllowFiltering:=True         '保护工作表并允许使用自动筛选功能
       End With
End Sub


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 免费注册

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-26 09:13 , Processed in 0.025136 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

返回顶部