[英]Run Excel macro to refresh pivot table in a password protected worksheet
我有一个名为 Inquiry 的密码保护工作表,其中包含允许用户刷新的 pivot 表。 刷新后,当工作表仍受密码保护时,pivot 表仍然可以像展开/折叠整个字段一样由用户使用。 因此,我在 Sub testprotect 中将 AllowUsingPivotTables 设置为 True。 下面是宏
Sub testprotect()
Worksheets("Enquiry").protect Password:=mypass, DrawingObjects:=True, Contents:=True, Scenarios:=True, _
UserInterfaceOnly:=True, AllowUsingPivotTables:=True
End Sub
Sub testunprotect()
Worksheets("Enquiry").unprotect "mypass"
End Sub
Sub testrefreshall()
ActiveWorkbook.RefreshAll
End Sub
Sub testeverything()
testunprotect
testrefreshall
testprotect
End Sub
我分别测试了 Sub testunprotect、testrefreshall 和 testprotect,它们都按预期工作。 但是当我在 Sub testeverything 中将它们组合在一起并运行它时,它给出了错误 - 当受保护的工作表包含另一个基于相同源数据的数据透视表时,无法执行该命令。 任何人都可以帮忙吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.