A couple of ways todo this;
Use On Error resume next OR try and handle the
error condition eg.
Sub clearUnlockedcells()
Dim ocell As Range
Dim datarg As Range
On Error Resume Next
Set datarg = [a1].SpecialCells(xlCellTypeConstants, 23)
If Err Then Exit Sub
For Each ocell In datarg
If ocell.MergeCells = False Then
ocell.Clear
End If
Next
End Sub
Sub clearUnlockedcells_2()
Dim ocell As Range
Dim datarg As Range
On Error Resume Next
Set datarg = [a1].SpecialCells(xlCellTypeConstants, 23)
For Each ocell In datarg
ocell.Clear
Next
End Sub
Ivan