|
楼主 |
发表于 2024-6-20 15:41
|
显示全部楼层
-4
- Public Sub ProteceSheet()
- Dim myWkb As Workbook
- Dim wks_MainSheet As Worksheet
- Dim myWks As Worksheet
- Dim iLastRow As Long, iLoop As Long
- Dim arr_SheetList()
-
- Set myWkb = ThisWorkbook
- Set wks_MainSheet = myWkb.Worksheets("MainSheet")
- With wks_MainSheet
- .Range("A:ZZ").EntireColumn.Hidden = False
- .AutoFilterMode = False
- iLastRow = .Range("A" & .Rows.Count).End(xlUp).Row
- If iLastRow <= 1 Then
- Call ShowMsgbox("MainSheet Sheet List Empty,Please Check it.", 2)
- Exit Sub
- End If
- arr_SheetList = .Range("A2:A" & iLastRow).Value
- End With
- For iLoop = 1 To UBound(arr_SheetList)
- Set myWks = myWkb.Worksheets(arr_SheetList(iLoop, 1))
- myWks.Protect Password:="1234", userinterfaceonly:=True, DrawingObjects:=True, Contents:=True, Scenarios:=True _
- , AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True
- myWks.EnableOutlining = True
- myWks.Range("J1:Z65536").Locked = False
- Next
- Call ShowMsgbox("Protect OK.", 1)
- End Sub
复制代码 |
|