PC Review


Reply
Thread Tools Rate Thread

Clear button

 
 
vdmbqb
Guest
Posts: n/a
 
      6th Apr 2008
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.
--
bob
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      6th Apr 2008
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


"vdmbqb" wrote:

> 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.
> --
> bob

 
Reply With Quote
 
dimm
Guest
Posts: n/a
 
      6th Apr 2008

Or a bit neater,

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

:-)
 
Reply With Quote
 
vdmbqb
Guest
Posts: n/a
 
      6th Apr 2008
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
--
bob


"Joel" wrote:

> 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
>
>
> "vdmbqb" wrote:
>
> > 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.
> > --
> > bob

 
Reply With Quote
 
dimm
Guest
Posts: n/a
 
      6th Apr 2008

Range("A1:A209").ClearContents

Or incorporated with your earlier ones:

Range("A1:A209,B77,S66").ClearContents
 
Reply With Quote
 
vdmbqb
Guest
Posts: n/a
 
      6th Apr 2008
Thank you-you guys are great!!
--
bob


"dimm" wrote:

>
> Range("A1:A209").ClearContents
>
> Or incorporated with your earlier ones:
>
> Range("A1:A209,B77,S66").ClearContents

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
clear button Sandra Teng Microsoft Access Form Coding 3 24th Jun 2009 08:38 PM
clear button YMC Microsoft Excel Programming 6 27th Feb 2008 04:44 PM
Create a Clear button to clear unprotected cells Jcraig713 Microsoft Excel Programming 2 26th Nov 2007 03:55 PM
clear button vdmbqb Microsoft Excel Misc 1 24th Nov 2007 04:52 PM
Clear Button JudyP Microsoft Excel Misc 2 5th Aug 2006 08:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:27 PM.