Can I lock data into few cells in sheet and clear the rest

E

eabrown

Using Office 2003, Excel Workbook. I want to enter data into certain cells,
lock them, enter data into the remainder of the sheet and later do a global
"clear contents" which will clear everything EXCEPT the data in the locked
cells. Is this possible?
 
D

Dave Peterson

Something like:

Option Explicit
Sub testme01()

Dim myCell As Range
Dim myRng As Range

Set myRng = Worksheets("sheet1").UsedRange

For Each myCell In myRng.Cells
If myCell.Locked Then
'skip it
Else
myCell.ClearContents
End If
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top