我正在运行一个宏,该宏在单元格值更改(带有密码)时自动保护工作表。此宏始终在所有打开的工作表中运行。应该是这样。但是,当我打开另一个 excel 文件时,它也会用密码保护该工作表。如何将宏限制为仅包含它的文件?
谢谢!
Private Sub Worksheet_Calculate()
Dim FormulaRange As Range
Dim FormulaRange2 As Range
Dim NotSentMsg As String
Dim MyMsg As String
Dim SentMsg As String
Dim MyLimit As Double
NotSentMsg = "Niet verzonden"
SentMsg = "Verzonden"
'Above the MyLimit value it will run the macro
MyLimit = 0
'Set the range with the Formula that you want to check
Set FormulaRange2 = ActiveSheet.Range("D22")
On Error GoTo EndMacro:
For Each FormulaCell In FormulaRange2.Cells
With FormulaCell
If IsNumeric(.Value) = False Then
MyMsg = "Not numeric"
Else
If .Value > MyLimit Then