Adding buttons in excel

You can insert form controls such as check boxes or option buttons to make data entry easier. Check boxes work well for forms with multiple options. Option buttons are better when your user has just one choice.

Sample check boxes
Sample radio button controls

To add either a check box or an option button, you’ll need the Developer tab on your Ribbon.

Notes: To enable the Developer tab, follow these instructions:

  • In Excel 2010 and subsequent versions, click File > Options > Customize Ribbon , select the Developer check box, and click OK.

  • In Excel 2007, click the Microsoft Office button Office button image > Excel Options > Popular > Show Developer tab in the Ribbon.

  1. To add a check box, click the Developer tab, click Insert, and under Form Controls, click Button image.

    the check box control on the ribbon

    To add an option button, click the Developer tab, click Insert, and under Form Controls, click Button image.

    the radio button control on the ribbon

  2. Click in the cell where you want to add the check box or option button control.

    Tip: You can only add one checkbox or option button at a time. To speed things up, after you add your first control, right-click it and select Copy > Paste.

  3. To edit or remove the default text for a control, click the control, and then update the text as needed.

    edit text for a form control

Tip: If you can’t see all of the text, click and drag one of the control handles until you can read it all. The size of the control and its distance from the text can’t be edited.

Formatting a control

After you insert a check box or option button, you might want to make sure that it works the way you want it to. For example, you might want to customize the appearance or properties.

Note: The size of the option button inside the control and its distance from its associated text cannot be adjusted.

  1. To format a control, right-click the control, and then click Format Control.

    the Format Control dialog box options

  2. In the Format Control dialog box, on the Control tab, you can modify any of the available options:

    • Checked: Displays an option button that is selected.

    • Unchecked: Displays an option button that is cleared.

    • In the Cell link box, enter a cell reference that contains the current state of the option button.

      The linked cell returns the number of the selected option button in the group of options. Use the same linked cell for all options in a group. The first option button returns a 1, the second option button returns a 2, and so on. If you have two or more option groups on the same worksheet, use a different linked cell for each option group.

      Use the returned number in a formula to respond to the selected option.

      For example, a personnel form, with a Job type group box, contains two option buttons labeled Full-time and Part-time linked to cell C1. After a user selects one of the two options, the following formula in cell D1 evaluates to «Full-time» if the first option button is selected or «Part-time» if the second option button is selected.

      =IF(C1=1,»Full-time»,»Part-time»)

      If you have three or more options to evaluate in the same group of options, you can use the CHOOSE or LOOKUP functions in a similar manner.

  3. Click OK.

Deleting a control

  • Right-click the control, and press DELETE.

Currently, you can’t use check box controls in Excel for the web. If you’re working in Excel for the web and you open a workbook that has check boxes or other controls (objects), you won’t be able to edit the workbook without removing these controls.

Important: If you see an «Edit in the browser?» or «Unsupported features» message and choose to edit the workbook in the browser anyway, all objects such as check boxes, combo boxes will be lost immediately. If this happens and you want these objects back, use Previous Versions to restore an earlier version.

If you have the Excel desktop application, click Open in Excel and add check boxes or option buttons.

Home / Excel Basics / How to Add a Button in Excel

In Excel, users can add macro-enabled buttons on the worksheets and can run macros by just clicking on them.

Users can use these macro-enabled buttons to perform several different tasks like filtering data, selecting data, printing a worksheet, running formulas, and calculations just by clicking on the buttons.

Adding buttons and embedding the macros to them is easier. Excel has multiple ways to add the macro-enabled buttons to the worksheet. Below, we have some quick and easy ways mentioned for you to add the macro buttons in Excel.

Add Macro Buttons Using Shapes

Users can create buttons in excel using shapes. Creating buttons using shapes has more formatting options over the buttons created from Control buttons or ActiveX buttons. Users can change the design, color, font, and style of the button created using shapes.

  1. First, go to the “Insert” tab and then click on the “Illustrations” icon” then click on the “Shapes” option and select any rectangle button.
    1-illustration-shapes-icon
  2. After that, with the help of a mouse, draw the rectangular button on the worksheet.
    2-draw-a-rectangular-button
  3.  Now, to enter the text in the button, double-click on the button and insert the text.
    3-enter-text-to-the-button
  4. For formatting, go to the “Shape Format” tab and you will get multiple options for the formatting of the button.
  5. From here, you can format the font style, font color, button color, button effects, and much more.
    4-shape-format-tab
  6. To edit the text, add the hyperlink, or add the macro, just right-click on the button and you will get the pop-up menu with multiple options.
  7. From here, you can edit the text, add the hyperlink, and can add the macro to the button.
  8. Now, select the “Assign Macro” option to add the macro to the button.
    5-right-click-on-the-button
  9. Once you select the “Assign Macro” option, you will get the “Assign Macro” dialogue box opened.
  10. From here, select the macro and click OK.
    6-assign-macro-window
  11. At this point, the button has become micro enabled, and when you move your cursor on the button, the cursor turns to the hand point cursor.
    7-micro-enabled-button
  12. To freeze the button movement, right-click on the button and select the “Format Shape” and select the option “Don’t move or size with cells”.
    8-freeze-the-button

Add Macro Buttons Using Form Controls

  1. First, go to the “Developer” tab and click on the “Insert” icon under the “Control” group on the ribbon.
    9-developer-tab
  2. After that, select the first button option from the “Form Controls” menu and draw a button on the worksheet.
    10-form-controls-button
  3. Now, select or type the macro name from the “Assign Macro” dialogue box and click OK.
  4. If you don’t have any macro created yet, you can click cancel to add the macro at a later stage.
    11-assign-macro-dialogue-box-
  5. From here, right-click on the button and select “Assign Macro” to add the macro to the button if did not assign yet.
  6. To format the button font size, style, color, etc. select the “Format Control” option.
    12-right-click-the-button
  7. Once you click on “Format Control”, you will get the “Format Control” window open and then can do the button font formatting.
    13-format-control-window
  8. To freeze the button movement, select the “Properties” tab and select the option “Don’t move or size with cells” and click OK.
    14-freeze-the-button-movement

Add Macro Buttons Using ActiveX Controls

  1. First, go to the “Developer” tab and click on the “Insert” icon under the “Control” group on the ribbon.
    15-developer-tab-insert-icon
  2. After that, select the first button option from the “ActiveX Controls” menu and draw a button on the worksheet.
    16-activex-controls-button
  3. Now, to create and insert the macro to the button, click on the “View Code” icon to launch the VBA editor.
    17-view-code
  4. Now, select the” CommandButton1” on the subprocedure and choose the “Click” option from the drop-down list on the right side of the editor.
    18-vba-editor

When we mention buttons in Excel, anyone who is not a consistent user will wonder what that means. Yes, Microsoft Excel does have Macros buttons which are the most advanced level of Excel. These buttons are commands initiated by a single click. It is easy to add buttons to excel. A user can simplify and save the time that they will take to navigate between different cells looking for specific information. In short, the buttons are inserted to perform specific tasks for us. The three different types of buttons you can place in a worksheet include;

  • Shapes
  • Form Control Buttons

This article shows how to add a button in Excel and how to assign Macros to them. With those buttons, navigating through your spreadsheet won’t be a nightmare anymore.

Method 1: Using shapes to create Macro buttons to open a particular sheet

You can create a macros button by using shapes. You can easily create a rounded rectangle; add a hyperlink to it for your worksheet. Here is what you can do;
1. On the main menu ribbon, click on the Insert tab.

2. Go to Shapes, click the drop-down arrow, and select the Rounded Rectangle icon.

3. Draw a rounded rectangle on your worksheet.

5. Format the shape by typing text into it-Right-click on the form and select edit text. Or double-click the shape.

6. To Hyperlink the shape, right-click on it and select Hyperlink from the menu. Right-clicking will display an Insert Hyperlink dialogue box.

  • Under the ‘Link to’ section, select ‘Place in This Document.
  • Under the ‘Type the cell reference’ section, type in the destination cell address.
  • Under the ‘Or select a place in this document box, click to choose the particular sheet name. Click the OK button when done.

When you click the rounded rectangle, it will skip to the specified cell of a specified sheet.

7. To assign the macro, right-click on the table and select Assign Macro. Under the ‘Macros in’ drop-down arrow, select ‘This Workbook’. Here, select the macro from the list of macros in This Workbook.

8. Press OK. When you point your mouse on this shape, it will turn to the hand pointer cursor, and clicking the form will run the macro. Remember to set your shape not to resize with cell changes by right-clicking on it and selecting ‘Size and Properties.’

Method 2: Using Developers Form Control Buttons to create buttons in Excel

1. On the main ribbon, click on the Developer tab.

2. Go to the Insert button and click the drop-down arrow.

3. Under Form Control, select the first option called button. Draw a button on your worksheet

4. Next, in the Assign Macro dialogue box, type or select a name for the macro.

5. Click OK when done. You can click on this button to run the macro.

Using ActiveX Controls

 Since running a macro in Excel can prove tedious, you can assign a macro to a button to run it faster. In this case, you can follow these steps to add a button in Excel using ActiveX controls easily.

1. Right-click anywhere on the Home ribbon and select Customize the Ribbon option from the pop-up menu. 

2. Once the Customize the Ribbon window is open, go to the Main Tabs section and select the Developer option.

3. Click OK. However, if you already have the Developer Tab added to your ribbon, then proceed as follows. 

4. Go to the Developer Tab and click on Insert.

5. Next, click on your preferred button under the ActiveX Controls.

You can now drag it anywhere in the Excel worksheet to create a button. 

6. Right-click on the newly created button and select the View Code option from the drop-down menu. 

7. You can now type this code, which sets the value of cell A6 to Hello:

Range(“A6”).Value = “Hello”

8. If you want to test setting the cell value, ensure the Design Mode option is deselected. You can also click on the button, and the Hello text will be displayed on your screen.

You can further use VBA codes to assign a different task for various operations such as double-clicking, single-clicking, right-clicking, and many more. When you right-click on the button, you can also select the Format Control option. However, the only downside is that the size of the buttons changes every time you make changes on the worksheet or share it.

Adding Macros To Quick Access Toolbar

Adding macros to Quick Access Toolbar also allows you to create buttons in Excel and use them on any sheet in your present workbook. To do this, follow these steps:

1. Right-click on the arrow below the ribbon of the Excel workbook.

2. When the Customize Quick Access Toolbar screen opens, navigate and select More Commands at the bottom.

3. Select Macros in the Choose commands from the section. You can click on the down-facing arrow in the Popular Commands box.

4. Select the HighlightMaxValue option and click on the Add button.

5. You can now click on Modify to customize the symbol of the macro.

6. Select your preferred symbol from the provided list and hit the OK button.

7. Finish by clicking OK to add a button to your Excel workbook. If you want to run the HighlightMaxValue macro, simply click on the icon.

Conclusion

When working with adding buttons to Excel, it is best to keep it easy and straightforward. The above methods portray these as the steps are short and easy to follow. They are not only easy to set up, but they also give you different options for formatting.

Excel Buttons

In Excel, Buttons are used to call Macros. This tutorial will cover how to create Excel buttons, assign Macros to them, adjust their properties, and more.

By default, Excel macros are accessible in a list via the “Macros” button on the View ribbon.

Often though, you’ll want to provide easy access to a particular macro directly on your worksheet.  This can be achieved using a Button control.

A Button control looks like a Microsoft Windows button, and runs a macro when clicked.  It’s a much handier way to access your most commonly used macros, and is an easy way to expose custom functionality to other users of your workbook.

Run a Macro From a Button

To run a Macro from a button in Excel, simply click the button:

The Excel Developer Tab

Buttons are accessible via the Developer Tab.

Unfortunately, Excel hides the Developer tab by default.  If you don’t see the Developer Ribbon, follow these steps:

  • Click File > Options in the list on the left-hand border

Excel File Button

Excel Options

  • In the Options dialog select Customize Ribbon > Customize the Ribbon > Main Tabs and add a check-mark in the box for “Developer”, and click OK.

excel enable developer ribbon

Add a Macro Button

In Excel, select the Developer tab, then click on the “Insert” dropdown in the Controls section.  There are several types of controls divided into two sections, “Form Controls” and “ActiveX Controls”.

excel insert button

For now, just click on the Button control under “Form Controls”.  Next, move the mouse anywhere over the worksheet surface, then hold left-click and drag the mouse to draw the outline of a rectangle.  When you release left-click, a new dialog will appear titled “Assign Macro”.

Assigning a Macro to a Button

Here you can assign an existing Macro to the button, record a new macro, create a new macro from scratch using VBA, or click “Cancel” and return to your button later.

Assign Existing Macro to a Button

To assign an existing Macro, you simply select the macro’s name in the list, then click OK.

Edit an Existing Macro Before Assigning to a Button

To edit a macro before assigning it to the button, select the macro’s name in the list and click the “Edit” button (the “New” button text changes to “Edit”).

Record a Macro and Assign to Button

To record a new macro and assign it to the button, click “Record…”.  This brings up the Record Macro dialog, where you specify a name and click “OK”.  The button will be assigned that macro.  Meanwhile, Excel will remain in a recording state until you click “Stop Recording” in the “Code” section of the Developer tab.

Write VBA Procedure and Assign to Button

To write a new macro for the button, type a new name for your macro in the textbox at the top of the dialog, then click “New”.  Excel will bring up the VB Editor, in which you’ll see a new empty macro procedure with the name you entered.  This procedure will be stored in a new module, visible in the Project window.

Change Macro Assigned to Button

To change the Macro that’s assigned to a button, simply right-click the button and select Assign Macro:

Here you can see the assigned Macro and make any desired changes.

How to Adjust Button Properties in Excel

Move or Resize Excel Button

After you’ve placed a button, you can easily move or resize it.  To perform any of these actions, right-click on the button. Then you can left-click and drag the button to your desired location or resize it.

excel move and resize buttons

Rename Button

With the button selected, left-click on the button text to edit.

To add multiple lines, simple press the ENTER key.

macro new text

Format Button

To format other button properties, Right-Click > Format Control

Here you can adjust font sizes, and many other button properties:

excel button properties font

Of particular note is the “Properties” tab, which changes how the button behaves as surrounding rows and columns are inserted, deleted, resized, or hidden/unhidden.

excel format button properties

  • Move and size with cells: The button will move and resize when rows and columns are changed.
  • Move but don’t size with cells: The button will move, but not resize.
  • Don’t move or size with cells: The button will not move or resize.
  • Finally, Print Object can set the object to appear on printouts.  This is unchecked by default, but can be toggled on if desired.

Assign a Macro to a Shape

Besides buttons, macros can assigned to other objects like Pictures, Textboxes, and Shapes.  With a Picture or Shape, you can make a button that looks any way you like.  Excel includes a wide variety of customizable Shapes including polygons, arrows, banners, and more that may be better suited to your worksheet than a regular button control.

Shapes are accessed from the Insert tab:

excel insert shape

Select the shape you want from the Shape dropdown, draw it onto your worksheet as you would a button control, then right-click it and select “Assign Macro…” from the pop-up dialog.  The options are the same as assigning a macro to a button.

assign macro to a shape

Assign a Macro to a Hyperlink

Macros can also be assigned to hyperlinks by using VBA Events. Events are procedures that are triggered when certain actions are performed:

  • Open/Close/Save Workbook
  • Activate / Deactivate Worksheet
  • Cell Values Change
  • Click Hyperlink
  • and more.

Events require knowledge of VBA.  To learn more about events, visit our VBA Tutorial.

Microsoft Excel lets you add two types of buttons to a worksheet: option buttons and toggle buttons. Option buttons, also referred to as radio buttons, let you choose one item from a list. Toggle buttons are either enabled or disabled, allowing you to switch between two states, such as on and off. Once a button is inserted into your worksheet, you then assign it form or ActiveX controls to make it perform an action when clicked.

Option Button

  1. Open Excel and Click on «Developer» Tab

  2. Open Excel and click on the «Developer» tab. If it’s not visible, click “File,” “Options” and then “Customize Ribbon.” Click the “Developer” check box within the Main Tabs list and click the «OK» button when you’re finished.

  3. Select «Insert»

  4. Select “Insert” from the Controls group on the Developer tab.

  5. Choose the Type of Button

  6. Click the type of option button you’d like to insert. Form Control and ActiveX Control are the two main categories. To insert a Form Control option button, click “Option Button” from the list of Form Controls. The names of the buttons appear when you hover the mouse over them. To insert an ActiveX Control option button, click “Option Button” from the list of ActiveX Controls.

  7. Click the Cell on Your Worksheet

  8. Click the cell on your worksheet where you want your option button displayed.

  9. Format the Button

  10. Format or edit your button properties to make it do something when clicked. For example, if you inserted a Form Control option button, right-click it and select “Format Control” from the drop-down menu to edit its properties. If you inserted an ActiveX Control button, right click your button and select “Properties» from the drop-down menu.

Toggle Button

  1. Click «Insert» in Controls Group

  2. Click “Insert” in the Controls group on the Developer tab in Excel.

  3. Select «Toggle Button»

  4. Select “Toggle Button” from the list of ActiveX Controls.

  5. Click where Button Should Appear

  6. Click your cursor in worksheet cell where you’d like the toggle button to appear.

  7. Select «Properties»

  8. Right-click the button and select “Properties” to assign ActiveX controls to it.

  9. Tip

    You can also assign macro controls to option buttons. With an option button inserted into your worksheet, right-click it and select “Assign Macro.” Choose the macro you’d like to use from the pop-up dialog box and then press “OK.”

Понравилась статья? Поделить с друзьями:
  • Adding bookmark in word
  • Adding an hour in excel
  • Adding a template to excel
  • Adding a tag in word
  • Adding a series to a chart in excel