View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AJPendragon AJPendragon is offline
external usenet poster
 
Posts: 4
Default Protect Cells After Input - help with macro

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