Clear button

V

vdmbqb

I am looking for a Macro. I am trying to have a button on my spreadsheet that
when clicked will clear data in specific cells.

For instance, a button when clicked will clear data from cells A1, B77 and
S66.


By the way, I don't know how to make the button either.
 
J

Joel

there are two methods. One where you put the button on the worksheet and the
second where you put the button on the top of the worksheet in a tool bar.

Here is how to put the button on the worksheet
1) Excel Menu View - toolbats - Control toolbox
2) Press the rectangular button on the toolbar. Then press on the worksheet
where you want the button to be located. You can resize the button. right
click the button and change CAPTION which is the words that appear on the
button
3) Double click on button and a macro window will appear with two lines of
code. change this code to look like the following. Don't change the button
number. each button on the worksheet will have aq unique button number which
is the name of the button that appears in the property of the button. If you
change the name property of the button then the macro name has to be the same.

Private Sub CommandButton1_Click()

Range("A1").ClearContents
Range("B77").ClearContents
Range("S66").ClearContents

End Sub
 
V

vdmbqb

Joel,

Thank you-this works perfectly.
Just one question, is there a way to write the same code in a range. For
instance; clear cells A1 thru A209.

Thanks again
 
D

dimm

Range("A1:A209").ClearContents

Or incorporated with your earlier ones:

Range("A1:A209,B77,S66").ClearContents
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

clear cells macro 5
Using an action button. 4
Clear Cells Button 7
excel clear button 3
How do I set up a macro to clear data from a section? 1
Create a button to Clear Cells 3
Clear page 3
Excel macro help needed 0

Top