ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protected Worksheets with info that needs to be deleted. (https://www.excelbanter.com/excel-discussion-misc-queries/207211-protected-worksheets-info-needs-deleted.html)

Joe Clark

Protected Worksheets with info that needs to be deleted.
 
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?

Barb Reinhardt

Protected Worksheets with info that needs to be deleted.
 
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
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Joe Clark" wrote:

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?


Joe Clark[_2_]

Protected Worksheets with info that needs to be deleted.
 
Where do I input this information?

"Joe Clark" wrote:

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?


Barb Reinhardt

Protected Worksheets with info that needs to be deleted.
 
Alt F11
Insert a module
Paste this in.

Barb Reinhardt

"Joe Clark" wrote:

Where do I input this information?

"Joe Clark" wrote:

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?


Joe Clark[_2_]

Protected Worksheets with info that needs to be deleted.
 
I posted the info into the module, how do I run the module?

Thanks

"Barb Reinhardt" wrote:

Alt F11
Insert a module
Paste this in.

Barb Reinhardt

"Joe Clark" wrote:

Where do I input this information?

"Joe Clark" wrote:

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?


Barb Reinhardt

Protected Worksheets with info that needs to be deleted.
 
Select the sheet you want to update. Press F8. Run the macro.

Barb Reinhardt

"Joe Clark" wrote:

I posted the info into the module, how do I run the module?

Thanks

"Barb Reinhardt" wrote:

Alt F11
Insert a module
Paste this in.

Barb Reinhardt

"Joe Clark" wrote:

Where do I input this information?

"Joe Clark" wrote:

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?



All times are GMT +1. The time now is 02:49 PM.

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