| | Product Information Help and How-to Training Templates Related Products and Technologies Support and Feedback Technical Resources Additional Resources | Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.
Add or edit a macro for a control on a worksheet
For forms and ActiveX controls (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) , you can do the following: For more information about how to create and edit macros, see the Help section, Macros. What do you want to do?
Add or edit a macro for a form control
- Right-click the control, and then click Assign Macro.
The Assign Macros dialog box appears.
- To specify the location of an existing macro, select where the macro is located in the Macros in box by doing one of the following:
- Do one of the following:
Assign a macro Do one of the following: - Record a new macro Click Record, and when you finish recording the macro, on the Developer tab, in the Code group, click Stop Recording
. - Assign an existing macro Double-click a macro in the list or enter its name in the Macro name box.
- Create a new macro Click New and then, in the Visual Basic Editor (Visual Basic Editor: An environment in which you write new and edit existing Visual Basic for Applications code and procedures. The Visual Basic Editor contains a complete debugging toolset for finding syntax, run-time, and logic problems in your code.), write a new macro.
For more information about how to write macros, see Visual Basic Help (Microsoft Visual Basic Help: To get help for Visual Basic in Excel, point to Macro on the Tools menu, and then click Visual Basic Editor. On the Help menu, click Microsoft Visual Basic Help.).
Modify an assigned macro Do one of the following: - Edit the assigned macro Click the name of the macro in the Macro Name box, and then click Edit.
- Assign a different existing macro Double-click a macro in the list or enter its name in the Macro name box.
Top of Page
Add or edit a macro for an ActiveX control
- If the Developer tab is not available, display it.
Display the Developer tab
- Click the Microsoft Office Button
, and then click Excel Options. - In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
Note The Ribbon is a component of the Microsoft Office Fluent user interface.
- 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
.
- Select the control.
For more information, see Select or deselect controls on a worksheet. - on the Developer tab, in the Controls group, click View Code
. Note You can also edit an existing macro by right-clicking the control, and then clicking View Code.
- In the Visual Basic Editor (Visual Basic Editor: An environment in which you write new and edit existing Visual Basic for Applications code and procedures. The Visual Basic Editor contains a complete debugging toolset for finding syntax, run-time, and logic problems in your code.), write a new macro or change the existing macro.
For more information about how to write macros, see Visual Basic Help (Microsoft Visual Basic Help: To get help for Visual Basic in Excel, point to Macro on the Tools menu, and then click Visual Basic Editor. On the Help menu, click Microsoft Visual Basic Help.).
- After you finish writing the macro, click Close and Return to Microsoft Excel on the File menu in the Visual Basic Editor.
- After you finish designing the control, on the Developer tab, in the Controls group, turn off Design Mode
.
Top of Page
|