使用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