Protect Cells After Input - help with macro

A

AJPendragon

I want to protect cells once the user has entered data. I have the following
macro which I think fails to work because some of the cells in the Target
Range are merged>

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
Dim myCell As Range
Set myRng = Me.Range("A11:K33,")
If Intersect(Target, myRng) Is Nothing Then
Exit Sub
End If
Me.Unprotect Password:="al"
For Each myCell In Target.Cells
If myCell.Value = "" Then
Else
myCell.Locked = True
End If
Next myCell
Me.Protect Password:="al"
End Sub

Thanks for any help or suggestions.

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top