close

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.

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 amp; 2003quot;fshewquot; gt; wrote in message
...
gt; How can I clear unlocked cells and leave the locked ones. I tried a macro
gt; but what I am trying to clear was to large for the macro.
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
quot;Paul Bquot; wrote:

gt; fshew, try this,
gt;
gt; Sub Clear_Unlocked()
gt; Dim rngeCell As Range
gt; Application.ScreenUpdating = False
gt;
gt; For Each rngeCell In ActiveSheet.UsedRange.Cells
gt; If rngeCell.Locked = False Then rngeCell.ClearContents
gt; Next
gt; Application.ScreenUpdating = True
gt; End Sub
gt; --
gt; Paul B
gt; Always backup your data before trying something new
gt; Please post any response to the newsgroups so others can benefit from it
gt; Feedback on answers is always appreciated!
gt; Using Excel 2002 amp; 2003
gt;
gt;
gt; quot;fshewquot; gt; wrote in message
gt; ...
gt; gt; How can I clear unlocked cells and leave the locked ones. I tried a macro
gt; gt; but what I am trying to clear was to large for the macro.
gt;
gt;
gt;

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

quot;fshewquot; wrote:

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

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 Subquot;fshewquot; gt; wrote in message
...
gt;I get this message when trying. What am I doing wrong? Compile error.
gt; Expected end sub.
gt;
gt; ' Macro1 Macro
gt; ' Macro recorded 3/7/2006 by David Walters
gt; '
gt; ' Keyboard Shortcut: Ctrl n
gt; '
gt; Sub Clear_Unlocked()
gt; Dim rngeCell As Range
gt; Application.ScreenUpdating = False
gt;
gt; For Each rngeCell In ActiveSheet.UsedRange.Cells
gt; If rngeCell.Locked = False Then rngeCell.ClearContents
gt; Next
gt; Application.ScreenUpdating = True
gt; End Sub
gt;
gt;
gt;
gt;
gt;
gt;
gt; quot;Paul Bquot; wrote:
gt;
gt;gt; fshew, try this,
gt;gt;
gt;gt; Sub Clear_Unlocked()
gt;gt; Dim rngeCell As Range
gt;gt; Application.ScreenUpdating = False
gt;gt;
gt;gt; For Each rngeCell In ActiveSheet.UsedRange.Cells
gt;gt; If rngeCell.Locked = False Then rngeCell.ClearContents
gt;gt; Next
gt;gt; Application.ScreenUpdating = True
gt;gt; End Sub
gt;gt; --
gt;gt; Paul B
gt;gt; Always backup your data before trying something new
gt;gt; Please post any response to the newsgroups so others can benefit from it
gt;gt; Feedback on answers is always appreciated!
gt;gt; Using Excel 2002 amp; 2003
gt;gt;
gt;gt;
gt;gt; quot;fshewquot; gt; wrote in message
gt;gt; ...
gt;gt; gt; How can I clear unlocked cells and leave the locked ones. I tried a
gt;gt; gt; macro
gt;gt; gt; but what I am trying to clear was to large for the macro.
gt;gt;
gt;gt;
gt;gt;
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 quot;Filequot; 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 amp; 2003

quot;fshewquot; gt; wrote in message
...
gt; OK I put the code in. How do I then clear the cells?
gt;
gt; quot;fshewquot; wrote:
gt;
gt;gt; How can I clear unlocked cells and leave the locked ones. I tried a
gt;gt; macro
gt;gt; but what I am trying to clear was to large for the macro.

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()