Hi mowens74,
Thank you for providing a sample workbook. It makes testing the code a lot easier.
Try the following code:
Sub TestLockCellsContainingDataInRange()
ActiveSheet.Unprotect
Call LockCellsContainingDataInRange(Range("W3:X45"))
ActiveSheet.Protect
End Sub
Sub LockCellsContainingDataInRange(myInputRange As Range)
'This sets the 'Locked' attribute for all cells in the 'Input Range' that
'contain data that is NOT a Formula
'
'NOTE: It is the calling routine's responsibility to Unprotect the Sheet before
' calling this routine
Dim myRangeConstants As Range
'Unlock All Cells in the Range
myInputRange.Locked = False
'Find the Sub-Range of cells that contain Data
Set myRangeConstants = myInputRange.SpecialCells(xlCellTypeConstants)
'Lock All Cells that Contain Data
myRangeConstants.Locked = True
Debug.Print myRangeConstants.Address
'Clear Object Pointer
Set myRangeConstants = Nothing
End Sub
Lewis
Bookmarks