Identify unprotected cells in protected sheet and clear their
Seeing the other guys interruptions <g, your code is actually doubly
counter-productive.
By adding the select you slow it down, but by your code logic
If Not cell.Locked Then cell.Select
Selection.ClearContents
you not only do that but for non-locked cells you re-clear the last selected
cell (unnecessarily most of the time, and if the usedrange starts with
locked cells and you have a locked cell active, it will actually crash the
code.
Why did you add it?
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"NezRhodes" wrote in message
...
GReat Bob, thank you. I added a couple of touches to your script to make
it
run a little quicker ...
Sub test()
Dim cell As Range
Application.Calculation = xlManual
For Each cell In ActiveSheet.UsedRange
If Not cell.Locked Then cell.Select
Selection.ClearContents
Next cell
Application.Calculation = xlAutomatic
End Sub
"Bob Phillips" wrote:
Sub test()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If Not cell.Locked Then cell.ClearContents
Next cell
End Sub
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"NezRhodes" wrote in message
...
Hello Gurus
I would like to create some script that dynamically identifies
unprotected
cells in a worksheet and clears their contents
Thanks in advance!
|