United States

Published on February 2017 | Categories: Documents | Downloads: 110 | Comments: 0 | Views: 1271
of 7
Download PDF   Embed   Report

Comments

Content

United States (change) | All Microsoft Sites

Sign in to My Office Online (What's this?) | Sign in Home Products Help and How-to Downloads Clip Art Templates Microsoft Office Live

Top of Form Bottom of Form Microsoft Office Excel
þÿ

Search Excel 2007 Excel 2003 Office XP Office 2000 All Office Online Clip art and media All Microsoft.com Bing

Search Microsoft Office Excel » Excel Home Product Information » Overview » Top 10 Reasons to Try » See It in Action » Pricing Information » Free 60-day Trial » Buy Now Home > Products > Excel > Excel 2007 Help and How-to > Macros Email this link Printer-Friendly Version Share Del.icio.us Digg Facebook Live Favorites StumbleUpon Reddit Furl Yahoo! What is this? MySpace

Help and How-to » Excel 2007 Help » Excel 2003 Help » Excel 2002 Help » Excel 2000 Help Choose your version » Excel Web Access Training » Excel 2007 Training » Excel 2003 Training » Excel 2007 Demos » Excel 2003 Demos » Excel 2007 Webcasts » Excel 2003 Webcasts Templates » Excel Templates » Submit a Template Related Products and Technologies » Duet for Microsoft Office and SAP » SQL Server Data Mining Add-ins for the 2007 Office release Support and Feedback » Product Support » Send Us Your Comments Technical Resources » Developer Center » Office Resource Kit Additional Resources » Office Marketplace » Discussion Groups » Excel Solutions » Excel MVPs

Close Social bookmarking lets you store, organize, rate, share, and reach your favorite we related links are shared by many people, you can find a lot of what you are looking bookmarking sites. To share Office Online pages, find the content you want to shar desired social bookmarking site from the list by clicking on the corresponding icon sign-in for each site), and submit the bookmark information. Run a macro Applies to: Microsoft Office Excel 2007

Show All Hide All Tags button; code; commands; enable macros; macro; macro button; Quick Acces What are tags? There are several ways to run a macro (macro: An action or a set of actions that yo are recorded in the Visual Basic for Applications programming language.). You ca menu command. Depending on how a macro is assigned to run, you might also be combination shortcut key (shortcut key: A function key or key combination, such a out a menu command. In contrast, an access key is a key combination, such as ALT command, or control.), or by clicking a toolbar button or an area on an object, grap a macro automatically when you open a workbook. Note When you set the macro security level in Microsoft Office Excel to Disable will run only those macros that are digitally signed or stored in a trusted location, s macro that you want to run is not digitally signed or located in a trusted location, y level that enables all macros. For more information about how to change macro security settings, see Change ma What do you want to do? Run a macro Run a macro by pressing a CTRL combination shortcut key Run a macro by clicking a button on the Quick Access Toolbar Run a macro by clicking an area on a graphic object Run a macro automatically upon opening a workbook Run a macro If the Developer tab is not available, do the following to display it:

Click the Microsoft Office Button , and then click Excel Options. In the Popular category, under Top options for working with Excel, select the Show box, and then click OK. Note The Ribbon is a component of the Microsoft Office Fluent user interface. To set the security level temporarily to enable all macros, do the following: On the Developer tab, in the Code group, click Macro Security.

In the Macro Settings category, under Macro Settings, click Enable all macros (not

code can run), and then click OK. Note To help prevent potentially dangerous code from running, we recommend th that disable all macros after you finish working with macros. or more information a Change macro security settings in Excel. Open the workbook that contains the macro. On the Developer tab, in the Code group, click Macros. In the Macro name box, click the macro that you want to run. Do one of the following: To run a macro in an Excel workbook, click Run. Tip You can also press CTRL+F8 to run the macro. You can interrupt the execut To run a macro from a Microsoft Visual Basic module, click Edit, and then on the , or press F5. Top of Page Run a macro by pressing a CTRL combination shortcut key If the Developer tab is not available, do the following to display it:

Click the Microsoft Office Button , and then click Excel Options. In the Popular category, under Top options for working with Excel, select the Show box, and then click OK. Note The Ribbon is a component of the Microsoft Office Fluent user interface. On the Developer tab, in the Code group, click Macros.

In the Macro name box, click the macro that you want to assign to a CTRL combin Click Options. In the Shortcut key box, type any lowercase letter or uppercase letter that you want Note The shortcut key will override any equivalent default Excel shortcut key wh macro is open. For a list of CTRL combination shortcut keys that are already assign function keys. In the Description box, type a description of the macro. Click OK, and then click Cancel. Top of Page Run a macro by clicking a button on the Quick Access Toolbar

Click the Microsoft Office Button , and then click Excel Options. Click Customize, and then in the Choose commands from list, select Macros. In the list, click the macro that you created, and then click Add. To change the button image of the macro, select the macro in the box where it was Under Symbol, click the button image that you want to use. To change the name of the macro that is displayed when you rest the pointer on the the name that you want to use. Click OK to add the macro button to the Quick Access Toolbar.

On the Quick Access Toolbar, click the macro button. Top of Page Run a macro by clicking an area on a graphic object In the worksheet, select an existing graphic object, such as a picture, clip art, shape To create a hot spot on the existing object, on the Insert tab, in the Illustrations gro you want to use, and then draw that shape on the existing object.

Right-click the hot spot that you created, and then click Assign Macro on the shortc shows a list of commands relevant to a particular item. To display a shortcut menu, SHIFT+F10.). Do one of the following: To assign an existing macro to the graphic object, double-click the macro or enter i To record a new macro to assign to the selected graphic object, click Record. When Stop Recording on the Developer tab in the Code group. Tip You can also click Stop Recording on the left side of the status bar. To edit an existing macro, click the name of the macro in the Macro name box, and Click OK. In the worksheet, select the hot spot. Tip This displays the Drawing Tools, adding a Format tab.

On the Format tab, in the Shape Styles group, do the following: Click the arrow next to Shape Fill, and then click No Fill. Click the arrow next to Shape Outline, and then click No Outline. Top of Page Run a macro automatically upon opening a workbook If you record a macro and save it with the name "Auto_Open," the macro will run w contains the macro. Another way to automatically run a macro when you open a wo Basic for Applications (VBA) procedure in the Open event of the workbook by usi Basic Editor: An environment in which you write new and edit existing Visual Bas procedures. The Visual Basic Editor contains a complete debugging toolset for find problems in your code.). The Open event is a built-in workbook event that runs its open the workbook. Create an Auto_Open macro If the Developer tab is not available, do the following to display it:

Click the Microsoft Office Button , and then click Excel Options. In the Popular category, under Working with Excel and other Office applications, s and then click OK. To set the security level temporarily to enable all macros, do the following:

On the Developer tab, in the Code group, click Macro Security.

In the Macro Settings category, under Macro Settings, click Enable all macros (not code can run), and then click OK. Note To help prevent potentially dangerous code from running, we recommend th that disable all macros after you finish working with macros. If you want to save the macro with a particular workbook, open that workbook firs On the Developer tab, in the Code group, click Record Macro. In the Macro name box, type Auto_Open. In the Store macro in list, select the workbook where you want to store the macro. Tip If you want a macro to be available whenever you use Excel, select Personal Personal Macro Workbook, Excel creates a hidden personal macro workbook (Pers and saves the macro in this workbook. In Windows Vista, this workbook is saved i name\AppData\Local\Microsoft\Excel\XLStart folder. In Microsoft Windows XP, C:\Documents and Settings\user name\Application Data\Microsoft\Excel\XLStart f folder are opened automatically whenever Excel starts. If you want a macro in the p automatically in another workbook, you must also save that workbook in the XLSt opened when Excel starts. Click OK, and then perform the actions that you want to record. On the Developer tab, in the Code group, click Stop Recording . Tip You can also click Stop Recording on the left side of the status bar. Notes If you chose to save the macro in This Workbook or New Workbook in step 6, save XLStart folders. Recording an Auto_Open macro has the following limitations: If the workbook where you save the Auto_Open macro already contains a VBA pro procedure for the Open event will override all actions in the Auto_Open macro. An Auto_Open macro is ignored when a workbook is opened programmatically by An Auto_Open macro runs before any other workbooks open. Therefore, if you rec perform on the default Book1 workbook or on a workbook that is loaded from the X will fail when you restart Excel, because the macro runs before the default and star If you encounter these limitations, instead of recording an Auto_Open macro, you Open event as described in the next section of this article. If you want Excel to start without running an Auto_Open macro, hold down the SH Create a VBA procedure for the Open event of a workbook The following example uses the Open event to run a macro when you open the wor If the Developer tab is not available, do the following to display it:

Click the Microsoft Office Button , and then click Excel Options. In the Popular category, under Working with Excel and other Office applications, s and then click OK. To set the security level temporarily to enable all macros, do the following:

On the Developer tab, in the Code group, click Macro Security.

In the Macro Settings category, under Macro Settings, click Enable all macros (not code can run), and then click OK. Note To help prevent potentially dangerous code from running, we recommend th that disable all macros after you finish working with macros. Save and close all open workbooks. Open the workbook where you want to add the macro, or create a new workbook. On the Developer tab, in the Code group, click Visual Basic. In the Project Explorer window, right-click the ThisWorkbook object, and then clic Tip In the Project Explorer window is not visible, on the View menu, click Projec In the Object list above the Code window, select Workbook. This automatically creates an empty procedure for the Open event such as this: Private Sub Workbook_Open()

End Sub Add the following lines of code to the procedure: Private Sub Workbook_Open() MsgBox Date Worksheets("Sheet1").Range("A1").Value = Date End Sub Switch to Excel and save the workbook as a macro-enabled workbook (.xlsm). Close and reopen the workbook. When you open the file again, Excel runs the Wor displays today's date in a message box. Click OK in the message box. Note that cell A1 on Sheet1 also contains the date as a result of running the Workb Top of Page Related Office Online discussions Read related questions and answers from other Microsoft Office customers. Re: Enable Macros Pop-Up Dialog Box??? Get macro to run on any worksheet without renaming the sheet? Set macro to run automatically when closing workbook? How do I Assign Macro to a button? Was this information helpful?

Please tell Microsoft how this information was helpful (optional): Please tell Microsoft how we can make this information more helpful (optional): Please tell Microsoft what you were trying to do (optional):

Your feedback is being submitted. Thank you for submitting your feedback to Microsoft. Change my feedback Although Microsoft cannot respond to every comment, we do use your feedback to improve the information we provide. Do you need support, or do you have a suggestion about a product? Contact us. See Also Audio course: Sign your own macros for stronger security Change macro security settings in Excel Create or delete a macro Customize keyboard shortcuts in Word Edit a macro Enable or disable macros in Office documents Get in the loop with Excel macros View my options and settings in the Trust Center advertisement Printer-Friendly Version Related Web Sites » Product Support » Microsoft » Microsoft.com Update » TechNet » Office Developer » Office for Mac Center » Office » Advertise with Community Us

Site Help | Accessibility | Contact Us | My Office Online | Office Worldwide © 2010 Microsoft Corporation. All rights reserved. Legal | Trademarks | Privacy Statement 16

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close