如何使用函数作为参数? [英] How do I Use a Function as a Parameter?
本文介绍了如何使用函数作为参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个可以取消保护和重新保护我的工作表的功能.
I would like a function that will unprotect and reprotect my Worksheet.
我目前拥有的功能如下:
The function I have currently is as follows:
Public Function RunProtect(fun As Function, sheet As Worksheet)
Dim protected As Boolean: protected = False
If sheet.ProtectContents = True Then
protected = True
sheet.Unprotect
End If
'Code to run fun
If protected = True Then
sheet.protect
End If
End Function
这是否可行,或者有更简单的方法吗?尝试使用VBA编辑表格时,我必须取消保护工作表的保护.
Is this possible or is there an easier way? I have to unprotect my sheets when trying to edit my tables in using VBA.
推荐答案
使用UserInterfaceOnly:=true
保护一次,您无需每次都取消保护. -GSerg
Protect once with UserInterfaceOnly:=true
, and you won't need to unprotect each time. -GSerg
谢谢!
这篇关于如何使用函数作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文