Need your help, please:
The following code works OK to "lock" all sheets in the workbook. For example, if there are 5 sheets and if I triger this code while in sheet 4, it locks all sheets including sheet 5. If there is no sheet 5, it locks all sheets up to 4. However, it is possible to have sheets more than the sheets you wish to "lock".
What I need is to lock only up to sheet 4 and not sheet 5. In other words, could you suggest a modification to the code so that it locks all sheets including the sheet the user is in and NOT the sheets higher.
Sub LockAllSheets()
If strMasterPassword = "" Then
strMasterPassword = Worksheets(1).Range("E100").Value
End If
Dim wsSheet As Worksheet
On Error Resume Next
For Each wsSheet In Worksheets
wsSheet.Unprotect password:=strMasterPassword
wsSheet.Activate
Range("$A$3:$K$84").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Cells.Select
Selection.Locked = True
Selection.FormulaHidden = False
wsSheet.Protect password:=strMasterPassword
Next wsSheet
On Error GoTo 0
End Sub