Buy online or Call 800-BUY-MYHP

Microsoft® Excel 2007: record a simple macro and edit it in VBA

Free, online classes, available 24/7: www.hp.com/go/learningcenter

Overview

Microsoft® Excel 2007: record a simple macro and edit it in VBA
» Microsoft® Excel 2007: record a simple macro and edit it in VBA  (3:28) Video
This animated demonstration shows you how to record a simple macro in Excel and edit it in VBA.
46 Ratings
 

Related topics

» Microsoft® Excel 2007: introduction
» Microsoft® Excel 2007: link and unlink content between two workbooks
» Microsoft® Excel 2007: create a PivotTable
» Microsoft® Excel 2007: filter data
» Microsoft® Excel 2007: intermediate

Transcript

Microsoft® Excel 2007: record a simple macro and edit it in VBA

If you need to perform the exact same steps multiple times, use an Excel macro.

With an Excel macro, it's best if you can record the steps efficiently with no extra actions. However, if you need to make some changes to a macro, you have the powerful VBA (Visual Basic for Applications) language available in the built-in Visual Basic editor. Just open the editor and edit your macro as needed.

In this demonstration, you'll learn how to edit a macro in the VBA editor.

First, let's record a simple macro and make an intentional error in it. Then we'll edit out the error in VBA.

On the Developer tab, click Record Macro.

Type a name for the macro.

Click OK.

Click the Home tab.

Click the Bold button.

Click OK.

Click the Italic button.

Clicking the Italic button is an intentional error for this demonstration.

Click OK.

Click the Stop Recording button on the status bar.

Click OK.

Now let's edit out the error in VBA.

Click the Developer tab.

Click the Macros button.

In the Macro dialog box, select the macro to edit.

Click Edit.

This macro is stored in the Personal Macro Workbook, which is hidden by default. You must unhide it before you can edit the macro.

Click OK.

Click Cancel.

Click the View tab.

Click the Unhide button.

Select the workbook to unhide, and then click OK.

Now the Personal Macro Workbook is visible.

Click the Developer tab.

Click the Macros button.

Select the macro to edit.

Click Edit.

The VBA editor window opens.

Select the line that refers to the Italic button.

Press Delete.

Click the Save button.

Close the editor window.

Now we'll test the macro by typing some text in a cell and applying the macro to it.

Click the Macros button.

Select the macro to run.

Click Run.

The macro applies bold formatting, but not italic.

In this demonstration, you learned how to edit a macro using the VBA language in Excel 2007's built-in VBA editor.

Class reviews

Nov 5, 2009

Macros

I would like to learn more complex macros. Great job though.

Oct 29, 2009
(Edited about 8 days ago)

macros

Somewhat helpful need a little more info on macros

Oct 24, 2009
(Edited about 13 days ago)

Record a simple macro and edit it in VBA

Awesome! This has provided me the missing information that I have been seeking in VBA setups.

Oct 19, 2009

Excel 2007

very good ,i'd like to learn more

» Read all 26 reviews

Write a review

» Please login to review
Printable versionPrintable version » Bookmark the Learning center E-mail this page Email this site
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2009 Hewlett-Packard Development Company, L.P.