ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Can I lock data into few cells in sheet and clear the rest (https://www.excelbanter.com/excel-discussion-misc-queries/71797-can-i-lock-data-into-few-cells-sheet-clear-rest.html)

eabrown

Can I lock data into few cells in sheet and clear the rest
 
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?

Dave Peterson

Can I lock data into few cells in sheet and clear the rest
 
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

eabrown wrote:

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?


--

Dave Peterson


All times are GMT +1. The time now is 02:38 AM.

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