Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button to clear cell contents automatically 1

Status
Not open for further replies.

netcert

Programmer
Apr 11, 2001
115
US
Is there a way in excel to create a button or something that once pressed it would clear the contents of a specified range of cells? Say if I had data:

A B C D E
1 5 4 12 1 3
2 3 0 0 0 0
3 3 6 1 0 0
4 1 2 5 0 2
5 2 1 7 9 3

Now instead of having to manually delete A1:C3 each time I wanted to be able to press a button somewhere and delete the contents of A1:C3 not the actual cells but the contents of them?

There may not be an answer but just curious.
 
Hi,

YES!

Use the COntrol Toolbox to place a CommandButton on your sheet.

Double cick the CommandButton and you will see the CommandButton1_Click event.

Paste this code in your VBA Editor and modify to suite your range
Code:
Private Sub CommandButton1_Click()
  ActiveSheet.Range("A1:C3").ClearContents
End Sub
On your sheet, be sure to turn off the Control Toolbox Editor.

:)



Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Skip,

I've got the button created but cannot figure out what you mean by turning the Toolbox Editor off. Is that does as simply as View > Toolbars and unchecking the Control Toolbox so it does not show on the worksheet any more is there something else?
 
On the toolbar is a green TRIANGLE -- Design Mode

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
oooooooo. aaaaahhhh. VERY COOL Skip!

Thanks so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top