LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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!






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to clear contents of unprotected cells AND drop down boxes JB2010 Excel Discussion (Misc queries) 3 March 30th 06 10:13 AM
How do I Clear ALL unprotected data entry fields in a protected sh bobreese Excel Programming 5 October 17th 05 01:47 PM
Allow unprotected cells to spell check after sheet is protected Numberonekraut (Hans) Excel Worksheet Functions 1 September 15th 05 07:55 PM
Tab key don't work in unprotected cells in a protected sheet Chad Excel Discussion (Misc queries) 0 August 16th 05 02:00 AM
Clear contents of unprotected cells in entire workbook with a macr FinnGirl Excel Programming 1 June 29th 05 05:32 PM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"