Click buttons in excel

Содержание

  1. Assign a macro to a Form or a Control button
  2. Add a button (Form control)
  3. Add a command button (ActiveX control)
  4. Add a button (Form control)
  5. Add a command button (Visual Basic control)
  6. Need more help?
  7. Add a Button and Assign a Macro in Excel
  8. Excel Buttons
  9. Run a Macro From a Button
  10. The Excel Developer Tab
  11. Add a Macro Button
  12. Assigning a Macro to a Button
  13. Assign Existing Macro to a Button
  14. Edit an Existing Macro Before Assigning to a Button
  15. Record a Macro and Assign to Button
  16. Write VBA Procedure and Assign to Button
  17. Change Macro Assigned to Button
  18. How to Adjust Button Properties in Excel
  19. Move or Resize Excel Button
  20. Rename Button
  21. Format Button
  22. Assign a Macro to a Shape
  23. Assign a Macro to a Hyperlink

Assign a macro to a Form or a Control button

You can use a Form control button or a command button (an ActiveX control) to run a macro that performs an action when a user clicks it. Both these buttons are also known as a push button, which can be set up to automate the printing of a worksheet, filtering data, or calculating 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)

In the sections below, learn how to add a macro to a button in Excel—for Windows or the Mac.

Note: ActiveX controls are not supported on the Mac.

Macros and VBA tools can be found on the Developer tab, which is hidden by default.

The first step is to enable it. For more information, see the article: Show the Developer tab.

Add a button (Form control)

On the Developer tab, in the Controls group, click Insert, and then under Form Controls, click Button .

Click the worksheet location where you want the upper-left corner of the button to appear. The Assign Macro popup window appears.

Assign a macro to the button, and then click OK.

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

Add a command button (ActiveX control)

On the Developer tab, in the Controls group, click Insert, and then under ActiveX Controls, click Command Button .

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

In the Controls group, click View Code. This launches the Visual Basic Editor. Ensure that Click is chose in the drop-down list on the right. The sub procedure CommandButton1_Click (see the figure below) runs these two macros when the button is clicked: SelectC15 and HelloMessage.

In the subprocedure for the command button, do either of the following:

Enter the name of an existing macro in the workbook. You can find macros by clicking Macros in the Code group. You can run multiple macros from a button by entering the macro names on separate lines inside the subprocedure.

As necessary, add your own VBA code.

Close the Visual Basic Editor, and click Design Mode to ensure design mode is off.

To run the VBA code that is now part of the button, click the ActiveX command button that you just created.

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.

To specify the control properties of the command button, on the Developer tab, in the Controls group, click Properties . 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 Visual Basic Help Search box. The following table summarizes the properties that are available.

If you want to specify

Use this property

Whether the control is loaded when the workbook is opened. (Ignored for ActiveX controls.)

Whether the control can receive focus and respond to user-generated 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.

Font attributes (bold, italic, size, strikethrough, underline, and weight).

Bold, Italic, Size, StrikeThrough, Underline, Weight (Form)

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.

Height, Width (Form)

The distance between the control and the left or top edge of the worksheet.

The background color.

The background style (transparent or opaque).

The foreground color.

Whether the control has a shadow.

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.

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.

Macros and VBA tools can be found on the Developer tab, which is hidden by default, so the first step is to enable it

Go to Excel > Preferences… > Ribbon & Toolbar.

In the Customize the Ribbon category, in the Main Tabs list, select the Developer check box, and then click Save.

Add a button (Form control)

Follow these steps:

On the Developer tab, click Button .

Click the worksheet location where you want the upper-left corner of the button to appear. The Assign Macro popup window appears.

Note: If you have already inserted a button, you can right-click on it, and select Assign Macro.

Assign a macro to the button and click OK.

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

Add a command button (Visual Basic control)

On the Developer tab, click Button .

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

Note: If you have already inserted a button, you can right-click on it, and select Assign Macro.

In the Assign Macro dialog box, select New, which will open the Visual Basic Editor ( VBE) to a pane with the following code:

In the subprocedure for the command button, between the Sub and End Sub lines, do either of the following:

Enter the name of an existing macro in the workbook. You can run multiple macros from a button by typing the macro names on separate lines inside the sub procedure

Add your own VBA code.

Click Design Mode to ensure that design mode is off, then close the Visual Basic Editor window.

To edit the button, right-click it and choose Visual Basic.

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

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Add a Button and Assign a Macro in Excel

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

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

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

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.

Rename Button

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

To add multiple lines, simple press the ENTER key.

Format Button

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

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

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.

  • 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:

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

Источник

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 More…Less

You can use a Form control button or a command button (an ActiveX control) to run a macro that performs an action when a user clicks it. Both these buttons are also known as a push button, which can be set up to automate the printing of a worksheet, filtering data, or calculating 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)

Example of a Forms toolbar button control

Command button (ActiveX control)

Example of an ActiveX command button control

In the sections below, learn how to add a macro to a button in Excel—for Windows or the Mac.

Note: ActiveX controls are not supported on the Mac.

Macros and VBA tools can be found on the Developer tab, which is hidden by default.

The first step is to enable it. For more information, see the article: Show the Developer tab.

Developer tab on the ribbon

Add a button (Form control)

  1. On the Developer tab, in the Controls group, click Insert, and then under Form Controls, click Button Button image .

  2. Click the worksheet location where you want the upper-left corner of the button to appear. The Assign Macro popup window appears.

  3. Assign a macro to the button, and then click OK.

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

Add a command button (ActiveX control)

  1. On the Developer tab, in the Controls group, click Insert, and then under ActiveX Controls, click Command Button Button image .

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

  3. In the Controls group, click View Code. This launches the Visual Basic Editor. Ensure that Click is chose in the drop-down list on the right. The sub procedure CommandButton1_Click (see the figure below) runs these two macros when the button is clicked: SelectC15 and HelloMessage.

    A subprocedure in the Visual Basic Editor

  4. In the subprocedure for the command button, do either of the following:

    • Enter the name of an existing macro in the workbook. You can find macros by clicking Macros in the Code group. You can run multiple macros from a button by entering the macro names on separate lines inside the subprocedure.

    • As necessary, add your own VBA code.

  5. Close the Visual Basic Editor, and click Design Mode Button image to ensure design mode is off.

  6. To run the VBA code that is now part of the button, click the ActiveX command button that you just created.

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

  8. To specify the control properties of the command button, on the Developer tab, in the Controls group, click Properties Button image . 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 Visual Basic Help Search box. The following table summarizes the properties that are available.

If you want to specify

Use this property

General:

Whether the control is loaded when the workbook is opened. (Ignored for ActiveX controls.)

AutoLoad (Excel)

Whether the control can receive focus and respond to user-generated events.

Enabled (Form)

Whether the control can be edited.

Locked (Form)

The name of the control.

Name (Form)

The way the control is attached to the cells below it (free floating, move but do not size, or move and size).

Placement (Excel)

Whether the control can be printed.

PrintObject (Excel)

Whether the control is visible or hidden.

Visible (Form)

Text:

Font attributes (bold, italic, size, strikethrough, underline, and weight).

Bold, Italic, Size, StrikeThrough, Underline, Weight (Form)

Descriptive text on the control that identifies or describes it.

Caption (Form)

Whether the contents of the control automatically wrap at the end of a line.

WordWrap (Form)

Size and Position:

Whether the size of the control automatically adjusts to display all the contents.

AutoSize (Form)

The height or width in points.

Height, Width (Form)

The distance between the control and the left or top edge of the worksheet.

Left, Top (Form)

Formatting:

The background color.

BackColor (Form)

The background style (transparent or opaque).

BackStyle (Form)

The foreground color.

ForeColor (Form)

Whether the control has a shadow.

Shadow (Excel)

Image:

The bitmap to display in the control.

Picture (Form)

The location of the picture relative to its caption (left, top, right, and so on).

PicturePosition (Form)

Keyboard and Mouse:

The shortcut key for the control.

Accelerator (Form)

A custom mouse icon.

MouseIcon (Form)

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

MousePointer (Form)

Whether the control takes the focus when clicked.

TakeFocusOnClick (Form)


Macros and VBA tools can be found on the Developer tab, which is hidden by default, so the first step is to enable it

  1. Go to Excel > Preferences… > Ribbon & Toolbar.

  2. In the Customize the Ribbon category, in the Main Tabs list, select the Developer check box, and then click Save.

    Select the checkbox next to Developer to add it to the ribbon

Add a button (Form control)

Follow these steps:

  1. On the Developer tab, click Button Button image .

  2. Click the worksheet location where you want the upper-left corner of the button to appear. The Assign Macro popup window appears.

    Note: If you have already inserted a button, you can right-click on it, and select Assign Macro.

  3. Assign a macro to the button and click OK.

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

Add a command button (Visual Basic control)

  1. On the Developer tab, click Button Button image .

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

    Note: If you have already inserted a button, you can right-click on it, and select Assign Macro.

  3. In the Assign Macro dialog box, select New, which will open the Visual Basic Editor (VBE) to a pane with the following code:

      Sub ButtonX_Click() 
    
      End Sub

  4. In the subprocedure for the command button, between the Sub and End Sub lines, do either of the following:

    • Enter the name of an existing macro in the workbook. You can run multiple macros from a button by typing the macro names on separate lines inside the sub procedure

    • Add your own VBA code.

  5. Click Design Mode Button image to ensure that design mode is off, then close the Visual Basic Editor window.

  6. To edit the button, right-click it and choose Visual Basic.

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

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See Also

  • Add or edit a macro for a control on a worksheet

  • Enable or disable macros in Office files

  • Enable or disable ActiveX settings in Office files

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

This tutorial is a detailed guide to creating interesting actionable buttons in Excel. If you want to learn to automate your Excel sheets by adding interactive buttons to your records, then this tutorial is made for you. Once we have created macros, we will learn to edit them in Excel.

Wait, what? You don’t know what macros are? Go ahead and read this article -> How to Record Macros in Excel?

If you’re still reading, I assume that you know what macros are and how to record them. So, let’s get started with this fun guide to creating some actionable buttons that you can use in your sheets to automate your data.

The best part is, you don’t have to be a VBA guru to create actionable buttons in Excel because this tutorial requires you to have zero knowledge in VBA to get started! Here are the steps to create actionable buttons without VBA in Excel.

Steps to create interactive buttons in Excel

This button will allow you to store the values from a user form to the database in the backend, refresh the table, or do whatever you want them to do for you. Isn’t it cool? You can get the experience of turning your spreadsheets into professional software.

To get started, let’s take an example of a user data entry form with a non-interactive button illustration below it.

buttons in Excel

You need to create two worksheets, one with the user form and the other with the database table where the user form data will be stored.

buttons in Excel

We will first record a macro in which we manually execute the action that is going to be done by the Submit button.

Here’s how to create interactive buttons in MS Excel 2016.

Here are the steps to create buttons in MS Excel 2019. Please follow the steps carefully. I have used a simpler example to help you understand better.

random details 1
  • Fill in random user details in the form.
  • Go to the View tab.
  • Pull down on Macros.
  • Click Record Macro.
  • Give your macro a name.
submit macro
  • Click OK. Now that the macro recording has started, follow these steps carefully without clicking anywhere else.
  • After clicking OK, copy the random user data you just filled in.
  • Go to the Database worksheet.
  • Right-click on the first empty cell in the table.
  • Pull right on Paste Special.
  • Choose the Transpose icon.
  • Don’t click anywhere yet!
transpose

Now that the first user entry is pasted horizontally, follow these final steps before ending the recording.

  • Go to the Home tab.
  • In the Cells group, pull down on Insert.
  • Click on Insert sheet rows.
  • Lastly, click on the first empty cell of the table again.
  • Don’t click anywhere yet!
new row
  • Navigate back to the user form sheet.
  • Delete the random entries you created from the cells.
  • Click on an empty cell in the sheet.
  • Stop recording the macro from the ribbon below, use your custom shortcut key, or choose Stop Recording from Macros in the View tab.

Woohoo, our macro is ready to be assigned to the Submit button!

assign macro
assign submit
  • Right-click on the submit button.
  • Click Assign macro.
  • Choose This workbook from the Macros in option below.
  • Choose the macro you just created.
  • Click OK.

Yay! It’s time to test your interactive button!

  • Clear all entries from the database sheet.
  • Fill in random user data in the form and click on the Submit button.
  • Navigate to the database sheet to check if the data is stored correctly.
  • Check with multiple user data to ensure everything working smoothly.

Conclusion

This tutorial was a detailed guide to creating interactive and actionable buttons in Excel without VBA. With this tutorial, you can easily automate any dataset and transform your works into smart and manageable records. Stay tuned at QuickExcel to learn more about smart Excel automation!

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

Как сделать кнопку в Excel? Войдите в раздел «Разработчик», откройте меню «Вставить», выберите изображение и назначьте макрос, гиперссылку, переход на другой лист или иную функцию. Ниже подробно рассмотрим все способы создания клавиш в Эксель, а также приведем функции, которые им можно присвоить.

Как создать кнопку: базовые варианты

Перед тем как сделать кнопку в Эксель, убедитесь в наличии режима разработчика. Если такой вкладки нет, сделайте следующие шаги:

  1. Жмите по ленте правой клавишей мышки (ПКМ).
  2. В появившемся меню кликните на пункт «Настройка ленты …».
  3. В окне «Настроить ленту» поставьте флажок возле «Разработчик».
  4. Кликните «ОК».

После того, как сделана подготовительная работа, можно вставить кнопку в Excel. Для этого можно использовать один из рассмотренных ниже способов.

Через ActiveX

Основной способ, как создать кнопку в Excel — сделать это через ActiveX. Следуйте такому алгоритму:

  1. Войдите в раздел «Разработчик».
  2. Жмите на кнопку «Вставить».
  3. В появившемся меню выберите интересующий элемент ActiveX.
  4. Нарисуйте его нужного размера.

Через элемент управления

Второй вариант — создание кнопки в Excel через элемент управления. Алгоритм действий такой:

  1. Перейдите в «Разработчик».
  2. Откройте панель «Вставить».
  3.  Выберите интересующий рисунок в разделе «Элемент управления формы».
  4. Нарисуйте нужный элемент.
  5. Назначьте макрос или другую функцию.

Через раздел фигур

Следующий способ, как добавить кнопку в Excel на лист — сделать это с помощью раздела «Фигуры». Алгоритм действий такой:

  1. Перейдите в раздел «Вставка».
  2. Войдите в меню «Иллюстрации», где выберите оптимальную фигуру.
  3. Нарисуйте изображение необходимой формы и размера.
  4. Кликните ПКМ по готовой фигуре и измените оформление.

В качестве рисунка

Вставка кнопки Excel доступна также в виде рисунка. Для достижения результата пройдите такие шаги:

  1. Перейдите во вкладку «Вставка».
  2. Кликните в категорию «Иллюстрации».
  3. Выберите «Рисунок».
  4. Определитесь с типом клавиши, который предлагается программой.

Какие кнопки можно создать

В Excel возможно добавление кнопки двух видов:

  1. Command Button — срабатывает путем нажатия, запускает определенное действие (указывается индивидуально). Является наиболее востребованным вариантом и может играть роль ссылки на страницу, таблицу, ячейку и т. д.
  2. Toggle Button — играет роль переключателя / выключателя. Может нести определенные сведения и скрывать в себе два параметра — Faste и True. Это соответствует двум состояниям — нажато и отжато.

Также перед тем как поставить кнопку в Эксель, нужно определиться с ее назначением. От этого напрямую зависят дальнейшие шаги. Рассмотрим разные варианты.

Макрос

Часто бывают ситуации, когда необходимо создать кнопку макроса в Excel, чтобы она выполняла определенные задачи. В обычном режиме для запуска нужно каждый раз переходить в раздел разработчика, что требует потери времени. Проще создать рабочую клавишу и нажимать ее по мере неободимости.

Если вы решили сделать клавишу с помощью ActiveX, алгоритм будет таким:

  • Войдите в «Режим конструктора».

  • Кликните дважды по ней.
  • В режиме Visual Basic между двумя строками впишите команду, необходимую для вызова макроса., к примеру, Call Макрос1.

  • Установите назначение для остальных графических объектов, если они есть.

Зная, как назначить кнопку в Excel, вы легко справитесь с задачей. Но можно сделать еще проще — жмите на рисунок ПКМ и в списке внизу перейдите в раздел «Назначить макрос». Здесь уже задайте интересующую команду.

Переход на другой лист / ячейку / документ

При желании можно сделать кнопку в Excel, которая будет отправлять к другому документу, ячейке или листу. Для этого сделайте следующее:

  • Подготовьте клавишу по схеме, которая рассмотрена выше.
  • Выделите ее.
  • На вкладке «Вставка» отыщите «Гиперссылка».

  • Выберите подходящий вариант. Это может быть файл, веб-страница, e-mail, новый документ или другое место.
  • Укажите путь.

Рассмотренный метод не требует указания макросов и предоставляет расширенные возможности. При желании можно также использовать и макросы.

Существует и другой способ, как сделать кнопку в Excel для перехода к определенному листу. Алгоритм такой:

  1. Создайте рисунок по рассмотренной выше схеме.
  2. В окне «Назначить макрос» введите имя макроса, а после жмите на клавишу входа в диалоговое окно Microsoft Visual Basic.
  3. Вставьте код для перехода к другому листу — ThisWorkbook.Sheets(«Sheet1»).Activate. Здесь вместо Sheet1 укажите путь к листу с учетом запроса.
  4. Сохраните код и закройте окно.

Сортировка таблиц

При желании можно сделать клавишу для сортировки таблиц Excel. Алгоритм действий такой:

  • Создайте текстовую таблицу.
  • Вместо заголовков добавьте автофигуры, которые в дальнейшем будут играть роль клавиш-ссылок на столбцах таблицы.

  • Войдите в Visual Basic режим, где в папке Modules вставьте модуль Module1.
  • Кликните ПКМ по папке и жмите на Insert Module.
  • Сделайте двойной клик по Module1 и введите код.
  • Назначьте каждой фигуре индивидуальный макрос.

После выполнения этих шагов достаточно нажать по заголовку, чтобы таблица сортировала данные в отношении определенного столбца.

По рассмотренным выше принципам несложно разобраться, как в Экселе сделать кнопки выбора и решения других задач. В комментариях расскажите, какой из приведенных методов вам подошел, и как проще всего самому сделать клавишу в программе.

Отличного Вам дня!

Понравилась статья? Поделить с друзьями:
  • Click and run word
  • Cleverer is not a word
  • Circle the word with a different sound food spoon cook
  • Clever word to use
  • Clever word for stupid