ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I delete only the content of cells that are NOT protected? (https://www.excelbanter.com/excel-discussion-misc-queries/187851-how-do-i-delete-only-content-cells-not-protected.html)

DrDisk7

How do I delete only the content of cells that are NOT protected?
 
In a selected range of a partial or whole worksheet, is there a way to clear
the content of the cells which are selected but are NOT protected (or not
marked as "locked" in an unprotected sheet) while keeping all formats and
locked/protected cells in that range untouched. -- Is there a way to disable
the protection error so that the delete/clear command can go and do its job
on the unprotected cells? Even the earliest spreadsheets had it! Is Excel too
restricted?

Gord Dibben

How do I delete only the content of cells that are NOT protected?
 
Sub UnlockedCells()
Dim cl As Range
For Each cl In ActiveSheet.UsedRange
If cl.Locked = False Then
cl.ClearContents
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Fri, 16 May 2008 20:39:00 -0700, DrDisk7
wrote:

In a selected range of a partial or whole worksheet, is there a way to clear
the content of the cells which are selected but are NOT protected (or not
marked as "locked" in an unprotected sheet) while keeping all formats and
locked/protected cells in that range untouched. -- Is there a way to disable
the protection error so that the delete/clear command can go and do its job
on the unprotected cells? Even the earliest spreadsheets had it! Is Excel too
restricted?




All times are GMT +1. The time now is 08:37 PM.

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