Excel保护工作表BeforeDoubleClick事件

如何使这个代码工作,然后表保护? 目标单元格不受保护(在属性中未选中)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not Intersect(Target, Range("printR")) Is Nothing Then Application.EnableEvents = False Cancel = True Target.ClearContents Application.EnableEvents = True End If End Sub 

你可以尝试在你的代码中包含这个地方

ActiveSheet.Unprotect Password:="123"

然后:

 Sheets("sheetName").Protect Password:="123" 

希望这可以帮助 :)