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.
If strMasterPassword = "" Then
strMasterPassword = Worksheets(1).Range("E100").Value
Dim wsSheet As Worksheet
On Error Resume Next
For Each wsSheet In Worksheets
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
Selection.Locked = True
Selection.FormulaHidden = False
On Error GoTo 0