【发布时间】:2011-07-08 17:02:42
【问题描述】:
使用 VBA 处理输入数据文件以创建受 Excel(2003) 保护的电子表格(发票)。 然后将电子表格分发到要修改某些指定单元格的其他办公室。 当整个工作表受到保护时,如何创建工作表以允许修改这些单元格? 我尝试过使用下面的代码和其他类似的变体,但它似乎不起作用。 你能帮忙吗?
Private Sub CellLock1()
Cells.Select
' unlock all the cells
Selection.Locked = False
' lock only these cells
Range("J49:K49").Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowInsertingColumns:=True, _
AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=True, _
AllowDeletingColumns:=True, _
AllowDeletingRows:=True, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowUsingPivotTables:=True
End Sub
【问题讨论】: