Hi all, I have a small code which will unprotect a sheet and insert a formula, but when i run it it says you have to unprotect it. Could you please have a look and point my mistake so that i could correct myself.
Thanks
Attaching the Code
Thanks
Attaching the Code
VBA Code:
Dim psheet As Worksheet
For Each psheet In Worksheets
If psheet.Name <> "Data Sheet" Or psheet.Name <> "Master Sheet" Or psheet.Name <> "Stock Check" Then
psheet.Unprotect Password:="STOCK"
Range("E3").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISBLANK(RC[-3]),,IF(RC[-3]=""Sales"",R[-1]C-1,R[-1]C+1))"
Range("E3").Select
Selection.AutoFill Destination:=Range("E3:E2000"), Type:=xlFillDefault
Range("E3:E2000").Select
Range("H11").Select
End If
Next psheet