View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to clear multiple cells of input data in Excel simultaneou

Do you have a worksheet named Sheet1 in the activeworkbook?

Change your code to match the name of the worksheet.

Gary wrote:

Duke,

I'm one step closer, but this macro won't run:
I get Run-tme error '9':
Script out of range

Sub ClearForm()
Dim c As Range
For Each c In Sheets("sheet1").UsedRange
If c.Locked = False Then
c.ClearContents
End If
Next

End Sub

What's wrong?

"Duke Carey" wrote:

sstea -

Change the line of code that reads

c.Value = ""

to

c..clearcontents



"sstea" wrote:

Thanks Corey
You rock man



"Corey" wrote:

Use this code

Dim c As Range
For Each c In Sheets("SHEET NAME HERE").UsedRange
If c.Locked = False Then
c.Value = ""
End If
Next

It will delete ALL cells values not locked in sheet selected


Corey....

"sstea" wrote in message
...
Yes, that is exactly what I want to do.

"Corey" wrote:

Does it mean to clear ALL cells in the sheet that are Not Locked ?

"sstea" wrote in message
...
I have a data input form in Excel where users enter values into unprotected
cells and view the result in a protected cell. I want the users to be able to
click a "button" to clear all of the previously entered cell input values simultaniously.







--

Dave Peterson