using button to clear contents

C

Charlie

I have finally found out how to add a button but now I am haveing a problem
on having the button clear contents in certain cells does anyone know how to
do this
thanks for your help I do not know any codes for this
 
G

Gord Dibben

I'll bet you could learn very quickly by using the macro recorder while you
select some cells and edit>clear>contents.

Here is a sample for a button from the Control Toolbox

Private Sub CommandButton1_Click()
ActiveSheet.Range("certain cells").ClearContents
End Sub

"certain cells" would be your range of cells.


Gord Dibben MS Excel MVP
 
D

Dave Peterson

Just to add to Gord's response.

If you want to clear the contents of the current selection, you could modify the
code to look like:

Private Sub CommandButton1_Click()
Selection.ClearContents
End Sub
 

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

Top