Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Making Command Buttons

I am trying to make a button in a spreadsheet to clear a
certain area. Example: Click on button and it will clear
range B1-B5. What book would I need to get to tell me how
to do this.
Rick
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Making Command Buttons

make the control toolbox toolbar visible (view=Toolbars, select Control
Toolbox)

click on the button icon

goto the worksheet and click where you want the upper left corner, keep the
mouse down and drag down and to the right to make it the size you want and
release the mouse button.

You are now in design mode with the button on the sheet. In the control
toolbox toolbar you will see the upper left icon, the one with the drawing
triangle, appears depressed. This shows you are in design mode.

Double click on the commandbutton and you will be taken to the click event
of the commandbutton - in the sheet module, the code module associated with
the worksheet where event related code is placed.

the code will look like

Private Sub CommandButton1_Click()

End Sub

Add the line of code

Private Sub CommandButton1_Click()
Range("B1:B5").ClearContents
End Sub

to return to the worksheet, click on the excel icon in the upper right
corner of the Visual Basic editor or do Alt+F11

Now click on that upper left icon with the drawing triangle to get out of
design mode.

Click your button and B1:B5 will be cleared.

David McRitchie has some listings of Excel related tutorials. VBA tutorials
follow that list:

http://www.mvps.org/dmcritchie/excel....htm#tutorials


--
Regards,
Tom Ogilvy





Rick wrote in message
...
I am trying to make a button in a spreadsheet to clear a
certain area. Example: Click on button and it will clear
range B1-B5. What book would I need to get to tell me how
to do this.
Rick



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Making Command Buttons

Rick, assign this to a button
Sub Clear_Cells()
[B1:B5].ClearContents
End Sub


--
Paul B
Always backup your data before trying something new
Using Excel 2000 & 97
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
"Rick" wrote in message
...
I am trying to make a button in a spreadsheet to clear a
certain area. Example: Click on button and it will clear
range B1-B5. What book would I need to get to tell me how
to do this.
Rick



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Buttons Hoyas07 Excel Discussion (Misc queries) 2 February 11th 08 03:42 PM
Help with command buttons Danno Excel Worksheet Functions 1 October 7th 05 10:32 PM
command buttons Natalie Excel Worksheet Functions 1 March 7th 05 01:45 PM
Control Buttons vs. Command Buttons Robert Gibson Excel Programming 1 October 13th 03 04:33 PM
Command buttons not available Donna Brooks Excel Programming 0 August 25th 03 04:23 PM


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"