ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing Contents of all "unprotected" Cells. (https://www.excelbanter.com/excel-programming/306172-clearing-contents-all-unprotected-cells.html)

Casey[_12_]

Clearing Contents of all "unprotected" Cells.
 
To the Great and Wise VBA Gurus,

Is there a VBA routine that would "clear contents" out of all th
unprotected cells on a worksheet, that could use the "UsedRange
property so that it could be utilized on worksheets of differin
sizes?

Many thanks in advance
Case

--
Message posted from http://www.ExcelForum.com


Gord Dibben

Clearing Contents of all "unprotected" Cells.
 
Casey

Try this.....clears contents of unlocked cells on all worksheets.

Adapt to suit.

Sub UnlockedCells()
Dim wk As Worksheet
Dim cl As Range
For Each wk In Worksheets
For Each cl In wk.UsedRange
If cl.Locked = False Then
cl.ClearContents
End If
Next
Next
End Sub

Gord Dibben Excel MVP

On Thu, 5 Aug 2004 17:31:08 -0500, Casey
wrote:

To the Great and Wise VBA Gurus,

Is there a VBA routine that would "clear contents" out of all the
unprotected cells on a worksheet, that could use the "UsedRange"
property so that it could be utilized on worksheets of differing
sizes?

Many thanks in advance
Casey


---
Message posted from http://www.ExcelForum.com/



Casey[_13_]

Clearing Contents of all "unprotected" Cells.
 
Gord,
A million thanks, our internet access has been down and I couldn't ge
back here to see if any one had replied. I try not to ask for cod
without a least first trying something on my own. But this was kind o
an emergency and you have made my day. Again, thank you

Case

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 04:20 AM.

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