Hi,
My knowledge here is very limited too. You need to put a protection/unprotection code and then call it before and after the procedure.
To protect
[vba]Sub Protect_Me()
With ActiveWorkbook
.Sheets("Sheet1").Protect Password:="My Password", AllowFormattingColumns:=True
'.Protect Password:="My Password", Structure:=True, Windows:=False ' <==== if you want to protect the workbook too then use this
End With
End Sub
[/vba]
Then you need to set up the Unprotect code
[vba]Sub Unprotect_Me()
With ActiveWorkbook
.Sheets("Sheet1").Unprotect Password:="My Password"
'.Unprotect Password:="My Password" ' <==== if you want to protect the workbook too then use this
End With
End Sub[/vba]
Now what you need to do is to call those from your main code.
[vba]
sub Main_routine
call Unprotect_Me
something like this
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then
Exit Sub
If Not Intersect(Target, Range("B4:B33"))
Is Nothing Then
'set your range here ActiveSheet.Unprotect Password:="pass"
Target.Locked = True
ActiveSheet.Protect Password:="pass" End If End Sub
call Protect_Me
[/vba]
Hope it helps