View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default clear cells macro

Sub UnLocked_Cells()
Dim cell As Range, tempR As Range, rangeToCheck As Range
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets(Array _
("Sheet2", "Sheet3", "Sheet4"))
ws.Activate
For Each cell In ActiveSheet.UsedRange
If Not cell.Locked Then
cell.ClearContents
End If
Next cell

Next ws
End Sub

You should get used to referring to worksheets as "sheets" rather than "pages"
which is generally used to designate printed sheets of paper.


Gord Dibben MS Excel MVP


On Sun, 6 Apr 2008 14:39:01 -0700, Dorothy
wrote:

To be more specific, I am trying to get a clear button on page one that when
clicked will clear all unprotected cells on pages 2, 3 and 4

"Dorothy" wrote:

I am looking to set up a clear button on sheet 1 that when clicked on will
clear various cells on sheet two.

I have a clear button on sheet 1 that when clicked clears cells on sheet 1
that reads;
Range("A1:A77").ClearContents

but when I try to put that cammand button on page one to clear cells on page
two I can't get the proper script that works.

any help is appreciated.

Dorothy