Excel VBA实现保护解锁所有的工作表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Public Function ProtectAllSheets()
Dim sheet As Worksheet
For Each sheet In ActiveWorkbook.Worksheets
sheet.EnableSelection = xlUnlockedCells
sheet.Protect Password:="Password", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True
Next sheet
End Function
 
Public Function UnprotectAllSheets()
Dim sheet As Worksheet
For Each sheet In ActiveWorkbook.Worksheets
sheet.Unprotect Password:="Password"
Next sheet
End Function

编程技巧