Clearing Unprotected Cells (Worksheet Resfresh ?)

zaHawk

New Member
Joined
Apr 21, 2011
Messages
41
Is there a way the resfresh the worksheet.. so it is a new quote sheet ?
I don't want to clear the whole sheet.. but only the cells needed for new entry

I use a page to temporary put in stock Items with prices.. and then I work out a temp quote for my customers.. once they go .. I delete all the cells I've just entered...
...but I am looking for a way to click a button.. and all fields (that are typed in) can instantly be cleared.

There is a long way.. to punch each cell into the button ... (done ages ago.. with Properties & code).. but is there a way to say clear all unprotected cells?
This way it will be much easier to format.. can it be done ?

Thank You
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You could use this on an unprotected sheet or modify it to match your protection
Code:
On Error Resume Next
With ActiveSheet
    .Protect ,true, true, true
    .UsedRange.Value = vbNullString
    .UnProtect
End With
On Error Goto 0
 
Last edited:
Upvote 0
I want to clear all unprotected cells.. within a sheet..
So I will give it a go... and attach it to a button

Thanks for the quick response ;)
 
Upvote 0
Just a touch of nomenclature.
Cells are "Locked", not "protected".
Worksheets or Workbooks are Protected, not "locked".

The distinction being that a locked cell can be altered by the user until the sheet is protected.
 
Upvote 0
This works well for me --- clears all unprotected cells
Option Explicit
Sub Button1_Click()
Dim rClear As Range
Dim rCl As Range
For Each rCl In ActiveSheet.UsedRange
If Not rCl.Locked = True Then
If rClear Is Nothing Then
Set rClear = rCl
Else: Set rClear = Union(rCl, rClear)
End If
End If
Next rCl
rClear.ClearContents
End Sub
 
Upvote 0
Just a touch of nomenclature.
Cells are "Locked", not "protected".
Worksheets or Workbooks are Protected, not "locked".

The distinction being that a locked cell can be altered by the user until the sheet is protected.
Thanks.. it works great !!! Can see why you are masters at this ;)

This works well for me --- clears all unprotected cells
I haven't tried yours.. but will. Thanks as well
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top