Protected Worksheets with info that needs to be deleted.

J

Joe Clark

Excell 2003. I have a worksheet that is protected, and people are allowed to
input data in the non-protected cells. Is there any way too highlight the
whole worksheet and delete the information that is in the non-protected cells
with out deleted the formulas in the protected cells?
 
B

Barb Reinhardt

Try this

Sub ClearUnlockedCells()
Dim myRange As Range
Dim r As Range
Dim aWS As Worksheet

Set aWS = ActiveSheet

Set myRange = Nothing
For Each r In aWS.UsedRange
If Not r.Locked Then
If myRange Is Nothing Then
Set myRange = r
Else
Set myRange = Union(myRange, r)
End If
End If
Next r

If Not myRange Is Nothing Then
myRange.ClearContents
End If
End Sub
 
B

Barb Reinhardt

Select the sheet you want to update. Press F8. Run the macro.

Barb Reinhardt
 

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

Top