使用VBA处理输入的数据文件以创建受Excel(2003)保护的电子表格(发票)。 然后将电子表格分发给其他需要修改指定单元格的办公室。 如何创建工作表以允许在整张工作表受到保护时修改这些单元格? 我曾尝试使用下面的代码和其他类似的变体,但它似乎不工作。 你能帮忙吗?如何在受保护的VBA创建的工作表上解锁单元格
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
你可以从我的例子,基本上是我在做什么见,但它不工作。我不能右键单击任何单元格,并且vba代码也不起作用。 – 2011-03-04 11:54:03
你说得对。在使用VBA解锁单元格之前,必须取消保护表单。我将用正确的解决方案编辑我的代码 – Kovags 2011-03-04 17:34:15