|
楼主 |
发表于 2024-6-20 15:29
|
显示全部楼层
-3
- Public Sub UnProteceSheet()
- Dim myWkb As Workbook
- Dim myWks As Worksheet
- Dim wks_MainSheet As Worksheet
- Dim iLastRow As Long, iLoop As Long
- Dim arr_SheetList()
- Dim sPsw As String
-
- On Error GoTo ErrorHandle
- 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
-
- sPsw = InputBox("Enter a protection password:")
- For iLoop = 1 To UBound(arr_SheetList)
- Set myWks = myWkb.Worksheets(arr_SheetList(iLoop, 1))
- myWks.Unprotect Password:=sPsw
- Next
- Call ShowMsgbox("UnProtect.", 1)
- Exit Sub
- ErrorHandle:
- Call ShowMsgbox("Password Error ,Please Check it.", 2)
- End Sub
复制代码 |
|