clear unlocked cells macro help please

C

CandiC

I have the following macro attached to a button on my "Price Estimator"
worksheet trying to clear contents in all of the unlocked cells of the
worksheet. Can someone please help me figure out what is wrong with the
following:

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

LMH

Is it as simple as missing End If and Next lines?

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

If that was just typo stuff in your query then maybe all cells are locked
(so nothing to do).
 
D

Don Guillett

Sub ClearForm()
Dim c As Range
For Each c In Sheets("PRICE ESTIMATOR").UsedRange
If c.Locked = False Then c.ClearContents
next c
End Sub
 
G

Gord Dibben

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


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top