【发布时间】:2010-09-25 21:33:58
【问题描述】:
以下 VBA 代码在 Excel 2003 中运行良好,但在 Excel 2007 中导致堆栈溢出错误。根据下拉菜单选择解锁或锁定某些单元格需要该代码.我需要能够在 Excel 2003 和 2007 中运行代码。请帮忙。
Private Sub Worksheet_Change(ByVal Target As Range)
If [E28] = "NO" Then
ActiveSheet.Unprotect ("PASSWORD")
[K47:K53].Locked = False
[K47:K53].Interior.ColorIndex = 16
[K47:K53].ClearContents
ActiveSheet.Protect ("PASSWORD")
Else
ActiveSheet.Unprotect ("PASSWORD")
[K47:K53].Interior.ColorIndex = 0
'Next line is optional, remove preceding apostrophe if protection should stay on.
ActiveSheet.Protect ("PASSWORD")
End If
End Sub
【问题讨论】:
-
这个网站的完美问题!
标签: vba excel-2007 locking cells