If Range("A5:d9").Locked Then
MsgBox "The range A5:D9 cell is protected"
I believe the above code will work if the whole range is locked but not if only a few cell within that range are. Try this:
Sub Identify_Locked_Cells()
Dim myRange As Range, rCell As Range
Dim strRange As String
Set myRange = Range("A5:D9")
For Each rCell In myRange
If rCell.Locked = True Then
If strRange = "" Then
strRange = rCell.Address
Else
strRange = strRange & ", " & rCell.Address
End If
End If
Next rCell
MsgBox ("The following cells are locked: " & strRange)
End Sub
Bookmarks