Читать книгу Excel 2019 Power Programming with VBA - Michael Alexander, Dick Kusleika - Страница 72

Editing your macro

Оглавление

After you record a macro, you can make changes to it. For example, assume that you want your name to be bold. You could re-record the macro, but this modification is simple, so editing the code is more efficient. Press Alt+F11 to activate the VB Editor window. Then activate Module1 and insert ActiveCell.Font.Bold = True, as demonstrated in the following sample code:

ActiveCell.Font.Bold = True

The edited macro appears as follows:

Sub MyName() '' MyName Macro '' Keyboard Shortcut: Ctrl+Shift+N ActiveCell.Font.Bold = True ActiveCell.FormulaR1C1 = "Michael Alexander" End Sub

Test this new macro, and you'll see that it performs as it should.

Excel 2019 Power Programming with VBA

Подняться наверх