Reset Button

bpgolferguy

Active Member
Joined
Mar 1, 2009
Messages
469
Is it possible to create a "reset" button in excel that when clicked will reset and clear everything that is in the unlocked cells the user can modify? If so, can you give me the macro code? Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub clr()
Dim c As Range
For Each c In ActiveSheet.UsedRange
    If c.Locked = False Then c.ClearContents
Next c
End Sub
 
Upvote 0

Diablo II

Well-known Member
Joined
Sep 28, 2008
Messages
538
ok for one the workbook is protected with some cells unlocked, and not Knowing the unloaked cell you can not wright code.

but you can type any thange in each cell that a user will type in, then hit record a macro and go to each cell and delet the info.

when you are done, stop the macro , theirs you reset.
 
Upvote 0

bpgolferguy

Active Member
Joined
Mar 1, 2009
Messages
469
That code listed above gives me an error message when I click the button....is that the exact code I should copy and paste into the code area? Do I need something before or after it?
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Can you post the exact code that you've assigned to the button. What's the error?
 
Upvote 0

bpgolferguy

Active Member
Joined
Mar 1, 2009
Messages
469
Here is the code:

Sub Button29_Click()
Sub clr()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If c.Locked = False Then c.ClearContents
Next c
End Sub
End Sub

It says "compile error"
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try this:

Code:
Sub Button29_Click()
Dim c As Range
For Each c In ActiveSheet.UsedRange
    If c.Locked = False Then c.ClearContents
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,191,586
Messages
5,987,502
Members
440,098
Latest member
MickyMouse123

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
Top