0

I have a protected sheet , but the cells B12:B27 are not locked . this code is not working with locked sheets. any idea?.

If Not Application.Intersect(Target, Range("B12:B37")) Is Nothing Then
    With Range("B" & ActiveCell.Row).Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="B,E,R,TG,TU,V"
    End With
End If

Thanks

1 Answer 1

2

When protecting the worksheet you have the option to allow deleting rows or deleting columns. Deleting individual cells is not an option because it could affect locked cells.

The .Delete command will remove the cell entirely, meaning the existing cells below or to the right will either need to be moved up or left respectively. If this is what you want to do, you will need to unprotect your sheet first.

ActiveSheet.Unprotect
' your code
ActiveSheet.Protect

If you just want to clear the contents of the cell, you can use

.ClearContents
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.