Button to reset form values

P

propolis

Hi,

I have entered some coding so that when my spreadsheet open, all user
values are set to zero (default values).

How do I add a button to my worksheet for the user to click on to reset
the values to there defaults while working on that sheet

:)
 
D

Dave Peterson

I'd create a named range and then just clear the cells in that named range.

Select your range of cells that should be cleared.
Insert|Name|Define|
and give it a nice name (I'll call it Input).

Then create a macro like this:

option Explicit
sub ClearInput()
worksheets("sheet1").range("Input").value = 0
end sub

The plop a button from the Forms toolbar and assign that macro to the button.

In fact, I think I'd verify the request just in case:

option Explicit
sub ClearInput()
Dim resp as long
resp = msgbox(Prompt:="Are you sure you want to reset to defaults?", _
buttons:=vbyesno)
if resp = vbno then
exit sub
end if
worksheets("sheet1").range("Input").value = 0
end sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top