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
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