How do I delete only the content of cells that are NOT protected?

  • Thread starter Thread starter DrDisk7
  • Start date Start date
D

DrDisk7

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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top