You are on page 1of 4

Add a button or command b...

Page 1

Excel > Forms

Add a button or command button to a worksheet


Show All You can use a button (a Form control) or a command button (an ActiveX control) to run a macro that performs an action when a user clicks it.

What do you want to do?


Learn about the button and the command button Add a button (Form control) Add a command button (ActiveX control)

Learn about the button and the command button


Both a Form control button and an ActiveX control command button are also referred to as a push button. You might use a button or a command button to automate the printing of a worksheet, the filtering of data, or the calculation of numbers. In general, a Form control button and an ActiveX control command button are similar in appearance and function. However, they do have a few differences, which are explained in the following sections.

Button (Form control)

Command button (ActiveX control)

Top of Page

Add a button (Form control)


1. If the Developer tab is not available, display it. Display the Developer tab 2. On the Developer tab, in the Controls group, click Insert, and then under Form Controls, click

ms-help://MS.EXCEL.12.1...

4/10/2010

4:22:55 PM

Add a button or command b...

Page 2

Button

3. 4.

Click the worksheet location where you want the upper-left corner of the button to appear. Assign a macro to the button. For more information about how to create and edit macros, see the Help section, Macros.

5.

To specify the control properties of the button, right-click the button, and then click Format Control.

Top of Page

Add a command button (ActiveX control)


1. If the Developer tab is not available, display it. Display the Developer tab 2. On the Developer tab, in the Controls group, click Insert, and then under ActiveX Controls, click Command Button .

3.

Click the worksheet location where you want the upper-left corner of the command button to appear.

4.

To edit the ActiveX control, make sure that you are in design mode. On the Developer tab, in the Controls group, turn on Design Mode .

5.

To specify the control properties of the command button, on the Developer tab, in the Controls group, click Properties .

TIP You can also right-click the command button, and then click Properties.

NOTE

Before you click Properties, make sure that the object for which you want to examine or

change properties is already selected. The Properties box appears. For detailed information about each property, select the property, and then press F1 to display a Visual Basic Help topic. You can also type the property name in the

ms-help://MS.EXCEL.12.1...

4/10/2010

4:22:55 PM

Add a button or command b...

Page 3

Visual Basic Help Search box. The following table summarizes the properties that are available. If you want to specify General: Whether the control is loaded when the workbook is opened. (Ignored for ActiveX controls.) Whether the control can receive focus and respond to usergenerated events. Whether the control can be edited. The name of the control. The way the control is attached to the cells below it (free floating, move but do not size, or move and size). Whether the control can be printed. Whether the control is visible or hidden. Text: Font attributes (bold, italic, size, strikethrough, underline, and weight). Descriptive text on the control that identifies or describes it. Whether the contents of the control automatically wrap at the end of a line. Size and Position: Whether the size of the control automatically adjusts to display all the contents. The height or width in points. The distance between the control and the left or top edge of the worksheet. Formatting: The background color. The background style (transparent or opaque). The foreground color. Whether the control has a shadow. Image: The bitmap to display in the control. The location of the picture relative to its caption (left, top, right, and so on). Keyboard and Mouse: The shortcut key for the control. A custom mouse icon. Accelerator (Form) MouseIcon (Form) Picture (Form) PicturePosition (Form) BackColor (Form) BackStyle (Form) ForeColor (Form) Shadow (Excel) Height, Width (Form) Left, Top (Form) AutoSize (Form) Bold, Italic, Size, StrikeThrough, Underline, Weight (Form) Caption (Form) WordWrap (Form) PrintObject (Excel) Visible (Form) Locked (Form) Name (Form) Placement (Excel) Enabled (Form) AutoLoad (Excel) Use this property

ms-help://MS.EXCEL.12.1...

4/10/2010

4:22:55 PM

Add a button or command b...

Page 4

The type of pointer that is displayed when the user positions the mouse over a particular object (standard, arrow, I-beam, and so on). Whether the control takes the focus when clicked. Top of Page

MousePointer (Form)

TakeFocusOnClick (Form)

See Also

Add an image control to a worksheet Add or edit a macro for a control on a worksheet Add or register an ActiveX control Edit text in a control on a worksheet Overview of forms, Form controls, and ActiveX controls on a worksheet Resize or format a control on a worksheet What can I do if I can't see or edit a cell because a control or object covers it? Why can't I select form and ActiveX controls?

ms-help://MS.EXCEL.12.1...

4/10/2010

4:22:55 PM

You might also like