ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Protect Cells After Input - help with macro (https://www.excelbanter.com/excel-worksheet-functions/210831-protect-cells-after-input-help-macro.html)

AJPendragon

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



All times are GMT +1. The time now is 04:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com