Главная » Excel Macros For Dummies читать онлайн | страница 23

Читать книгу Excel Macros For Dummies онлайн

23 страница из 60

 Press Alt+F11.

 Choose Developer ⇒ Code ⇒ Visual Basic.

 Choose Developer ⇒ Code ⇒ Macros, select a macro, and click Edit.

In the VB Editor, the Project window displays a list of all open workbooks and add-ins. If the Project Explorer isn’t visible, choose View ⇒ Project Explorer. This list is displayed as a tree diagram, which you can expand or collapse. The code that you recorded previously is stored in Module1 in the current workbook. When you double-click Module1, the code in the module appears in the Code window.

The macro should look something like this:

Sub MyName()'' MyName Macro'' Keyboard Shortcut: Ctrl+Shift+N' Range("B3").Select ActiveCell.FormulaR1C1 = "Dick Kusleika" Range("B4").SelectEnd Sub

The macro recorded is a Sub procedure named MyName. The statements tell Excel what to do when the macro is executed.

Notice that Excel inserted some comments at the top of the procedure. These comments are some of the information that appeared in the Record Macro dialog box. These comment lines (which begin with an apostrophe) aren’t really necessary, and deleting them has no effect on how the macro runs. If you ignore the comments, you'll see that this procedure has three VBA statements, the second of which is:

Правообладателям