Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AD AD is offline
external usenet poster
 
Posts: 9
Default Excel Formula

Is there a formula that will automatically clear ALL unprotected cells? i
have a spreadsheet and in lieu of erasing all the unprotected cells I am
hoping there is a formula that with just one click it will erase all of the
contents of the unproteced cells.

thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Excel Formula

Try this small macro:

Sub ClearUm()
Set r = ActiveSheet.UsedRange
For Each rr In r
If rr.Locked = True Then
Else
rr.Clear
End If
Next
End Sub

--
Gary''s Student - gsnu200907


"AD" wrote:

Is there a formula that will automatically clear ALL unprotected cells? i
have a spreadsheet and in lieu of erasing all the unprotected cells I am
hoping there is a formula that with just one click it will erase all of the
contents of the unproteced cells.

thanks for your help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel Formula

Formulas can't touch other cells. About the only thing that they can do is
return values to the cells that contain that formula.

But you can use a macro.

Do you really mean all the unlocked cells on a protected worksheet?

Option Explicit
Sub testme01()

Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Cells.SpecialCells(xlCellTypeConstants)
On Error GoTo 0
End With

If myRng Is Nothing Then
'no constants to clear
Else
For Each myCell In myRng.Cells
If myCell.Locked = False Then
myCell.ClearContents
End If
Next myCell
End If

End Sub

I limited my range to check to just the constants--no formulas. I figured that
if you have a formula on that worksheet, then it should be saved--even if the
cell isn't locked.



AD wrote:

Is there a formula that will automatically clear ALL unprotected cells? i
have a spreadsheet and in lieu of erasing all the unprotected cells I am
hoping there is a formula that with just one click it will erase all of the
contents of the unproteced cells.

thanks for your help


--

Dave Peterson
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
When I enter a formula, Excel shows the formula not the results Pat Adams Excel Worksheet Functions 5 April 4th 23 11:18 AM
Excel 2002 Formula: Urgent Conditional Formula Required Right Away - if possible blue[_2_] Excel Discussion (Misc queries) 2 July 11th 07 06:08 PM
Build excel formula using field values as text in the formula val kilbane Excel Worksheet Functions 2 April 18th 07 01:52 PM
Excel 2002 formula displayed not value formula option not checked Dean Excel Worksheet Functions 1 February 28th 06 02:31 PM
How do I view formula results intead of formula in excel? davidinatlanta Excel Worksheet Functions 4 February 7th 06 03:02 PM


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