Поэтому я пытался включить код для защиты всех рабочих листов в своем рабочем листе с использованием VBA с различными свойствами на листе. Я играл со следующим кодом, но по какой-то причине он защищает только некоторые листы паролем, а не другими. Пожалуйста, помогите.
Sub ProtegerTodo()
Sheets("Sheet1").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
Sheets("Sheet1").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
'Sheets("Sheet1").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
Sheets("Consecutivo de Cirugías").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
Sheets("Consecutivo de Cirugías").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
'Sheets("Sheet1").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
Sheets("Nueva CX").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
'Sheets("Nueva CX").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
Sheets("Nueva CX").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
Sheets("Catalogo").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
Sheets("Catalogo").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
'Sheets("Sheet1").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
Sheets("Procedimientos").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
Sheets("Procedimientos").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
'Sheets("Sheet1").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
Sheets("Inventario").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
Sheets("Inventario").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
'Sheets("Sheet1").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
Sheets("Ingreso de material").Protect Password:="Password", _
UserInterfaceOnly:=True, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=False
'Allowing selection of locked or unlocked cells
Sheets("Ingreso de material").EnableSelection = xlNoRestrictions
'Allowing selection of unlocked cells only
'Sheets("Sheet1").EnableSelection = xlUnlockedCells
'Do not allow selection of any cells
'Sheets("Sheet1").EnableSelection = xlNoSelection
End Sub
Примечание: я знаю, что это не очень эффективно, но это должно сработать.
Заранее спасибо.