Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
fshew
 
Posts: n/a
Default Clearing unlocked cells

How can I clear unlocked cells and leave the locked ones. I tried a macro
but what I am trying to clear was to large for the macro.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Paul B
 
Posts: n/a
Default Clearing unlocked cells

fshew, try this,

Sub Clear_Unlocked()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"fshew" wrote in message
...
How can I clear unlocked cells and leave the locked ones. I tried a macro
but what I am trying to clear was to large for the macro.



  #3   Report Post  
Posted to microsoft.public.excel.misc
fshew
 
Posts: n/a
Default Clearing unlocked cells

I get this message when trying. What am I doing wrong? Compile error.
Expected end sub.

' Macro1 Macro
' Macro recorded 3/7/2006 by David Walters
'
' Keyboard Shortcut: Ctrl+n
'
Sub Clear_Unlocked()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub






"Paul B" wrote:

fshew, try this,

Sub Clear_Unlocked()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"fshew" wrote in message
...
How can I clear unlocked cells and leave the locked ones. I tried a macro
but what I am trying to clear was to large for the macro.




  #4   Report Post  
Posted to microsoft.public.excel.misc
fshew
 
Posts: n/a
Default Clearing unlocked cells

OK I put the code in. How do I then clear the cells?

"fshew" wrote:

How can I clear unlocked cells and leave the locked ones. I tried a macro
but what I am trying to clear was to large for the macro.

  #5   Report Post  
Posted to microsoft.public.excel.misc
Paul B
 
Posts: n/a
Default Clearing unlocked cells

fshew, looks like you may have part of another macro in with it, but with
what you posted with it commented out looks like it should work, may want to
put this in a new module and try again

Sub Clear_Unlocked()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub


"fshew" wrote in message
...
I get this message when trying. What am I doing wrong? Compile error.
Expected end sub.

' Macro1 Macro
' Macro recorded 3/7/2006 by David Walters
'
' Keyboard Shortcut: Ctrl+n
'
Sub Clear_Unlocked()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub






"Paul B" wrote:

fshew, try this,

Sub Clear_Unlocked()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"fshew" wrote in message
...
How can I clear unlocked cells and leave the locked ones. I tried a
macro
but what I am trying to clear was to large for the macro.








  #6   Report Post  
Posted to microsoft.public.excel.misc
Paul B
 
Posts: n/a
Default Clearing unlocked cells

fshew,



To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is to the left of the "File" menu this will open
the VBA editor, in Project Explorer click on your workbook name, if you
don't see it press CTRL + r to open the Project Explorer, then go to insert,
module, and paste the code in the window that opens on the right hand side,
press Alt and Q to close this window and go back to your workbook and press
alt and F8, this will bring up a box to pick the Macro from, click on the
Macro name, Clear_Unlocked, to run it. If you are using excel 2000 or
newer you may have to change the macro security settings to get the macro to
run. To change the security settings go to tools, macro, security, security
level and set it to medium
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"fshew" wrote in message
...
OK I put the code in. How do I then clear the cells?

"fshew" wrote:

How can I clear unlocked cells and leave the locked ones. I tried a
macro
but what I am trying to clear was to large for the macro.



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
Locked spreadsheet, move cursor only to unlocked cells? dhilligoss Excel Worksheet Functions 1 December 5th 05 02:29 PM
Marking unlocked cells in active worksheet Zadig Galbaras Excel Discussion (Misc queries) 4 August 13th 05 08:05 PM
requires that merged cells must be identically sized? Catt Excel Discussion (Misc queries) 11 July 3rd 05 12:36 PM
Help adding text values Texas-DC_271 Excel Worksheet Functions 7 January 15th 05 11:14 PM
Convert data type of cells to Text,Number,Date and Time Kevin Excel Worksheet Functions 1 December 31st 04 12:57 PM


All times are GMT +1. The time now is 12:04 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"