Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Identify unprotected cells in protected sheet and clear their cont

Hello Gurus

I would like to create some script that dynamically identifies unprotected
cells in a worksheet and clears their contents

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Identify unprotected cells in protected sheet and clear their cont

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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Identify unprotected cells in protected sheet and clear their

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!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Identify unprotected cells in protected sheet and clear their

Good point. You might want to turn screenupdating off at the start and back
on at the end as well.

--
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!






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Identify unprotected cells in protected sheet and clear their

But Bob's code did not invlolve a .Select, as there no reason for it.
Selecting will only slow thing down.

NickHK

"NezRhodes" ...
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!








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Identify unprotected cells in protected sheet and clear their

I think you added stuff to make it faster (calculation mode stuff). But then
added stuff to make it slower--selection stuff.

Maybe dropping the .select/selection stuff would make it even quicker.

NezRhodes wrote:

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!





--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Identify unprotected cells in protected sheet and clear their

Dave,
Swing & roundabouts..

NicHK

"Dave Peterson"
...
I think you added stuff to make it faster (calculation mode stuff). But
then
added stuff to make it slower--selection stuff.

Maybe dropping the .select/selection stuff would make it even quicker.

NezRhodes wrote:

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!




--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Identify unprotected cells in protected sheet and clear their

That must have something to do with a hit and an error???

NickHK wrote:

Dave,
Swing & roundabouts..

NicHK

"Dave Peterson"
...
I think you added stuff to make it faster (calculation mode stuff). But
then
added stuff to make it slower--selection stuff.

Maybe dropping the .select/selection stuff would make it even quicker.

NezRhodes wrote:

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!




--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Identify unprotected cells in protected sheet and clear their

Dave,
http://www.phrases.org.uk/bulletin_b...sages/545.html

NickHK

"Dave Peterson"
...
That must have something to do with a hit and an error???

NickHK wrote:

Dave,
Swing & roundabouts..

NicHK

"Dave Peterson"
...
I think you added stuff to make it faster (calculation mode stuff). But
then
added stuff to make it slower--selection stuff.

Maybe dropping the .select/selection stuff would make it even quicker.

NezRhodes wrote:

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!




--

Dave Peterson


--

Dave Peterson



  #10   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!






Reply
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 09:24 PM.

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

About Us

"It's about Microsoft Excel"