ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   clear unlocked cells macro help please (https://www.excelbanter.com/excel-worksheet-functions/248433-clear-unlocked-cells-macro-help-please.html)

CandiC

clear unlocked cells macro help please
 
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




lmh

clear unlocked cells macro help please
 
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).
--
LMH


"CandiC" wrote:

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




Don Guillett

clear unlocked cells macro help please
 

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"CandiC" wrote in message
...
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





Gord Dibben

clear unlocked cells macro help please
 
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

On Fri, 13 Nov 2009 14:30:01 -0800, CandiC
wrote:

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





All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com