New Feature: Playlist Center! Pick a topic and let our playlists guide the way—like a learning mixtape.

Start learning with our library of video tutorials taught by experts. Get started

Excel 2003 Essential Training
Illustration by

Recording a macro


From:

Excel 2003 Essential Training

with Mark Swift

Video: Recording a macro

macros can be as simple as clicking Record on your VCR and recording actions that you take, then you can take that recorded file and play it back as often as you want to repeat those actions, or you can take that file and assign a shortcut key to it, you can assign it to your own custom menus, or you can drop an icon on the existing toolbar and utilize it any time you want with a simple click. The key to creating effective macros is knowing when to record your actions so that they become as useful as possible. We're going to see that right here. I should also note at this point that recording a macro records a complex VBA script. VBA is Visual Basic for Applications, and it really is a mini development environment that exists within the Office Suite. If you know how to script inside of VBA, you can create macros that really enhance the functionality of any of the applications inside the Office Suite. You can make your Excel spreadsheet look and feel more like a true application than anything else. We're going to stick to the simple record and playback method, which is how most people record macros and provides for more power than most people need anyway. Let's start by adding a row here in our spreadsheet, and in the first cell we'll type our title: QUARTERLY SALES. Now that we have our title created, let's begin recording a macro so that we can format this title, and then then we can do it again and again any time we need to format a title within a spreadsheet. Let's go up to the Tools menu and you'll expand this in case you don't see macro. You'll notice that the Macro's submenu is also where you access your Visual Basic Editor. We're going to click Record New Macro, and when we do we need to make a few choices. First the macro name. Let's call it TitleFormat. Now you can't use any special characters and you can't leave any spaces here. If you don't like having those two words together, put an underscore, but because this is also a filename, spaces are not allowed, and I'm going to use Control+F, and it's asking me where I want to store this macro. I can store this macro in a workbook, in other words it'll stick with this file or I can store it globally in my Personal Macro Workbook. I'm going to stick with the default for right now, and say OK. And you'll notice this small toolbar that's appeared. Now it's not literally recording you like a video recorder, but it is looking for actions and it's going to record each and every action that you take now within your spreadsheet. So let's start by selecting A1 through E1 and using on our toolbar the Merge and Center button.
Expand all | Collapse all
  1. 16s
    1. Welcome
      16s
  2. 22m 44s
    1. Spreadsheet uses
      1m 59s
    2. Toolbars and menus
      8m 53s
    3. Moving around
      8m 1s
    4. Getting help
      3m 51s
  3. 18m 43s
    1. Opening new workbooks
      5m 13s
    2. Entering data
      6m 12s
    3. Commenting and saving
      7m 18s
  4. 17m 31s
    1. Opening worksheets
      1m 55s
    2. Add and delete worksheets
      2m 23s
    3. Insert and delete cells
      3m 46s
    4. Worksheet data
      9m 27s
  5. 36m 0s
    1. Width and height
      6m 7s
    2. Numeric formats
      6m 1s
    3. Alignment of data
      3m 43s
    4. Naming cells and ranges
      5m 48s
    5. Naming constants
      1m 52s
    6. Creating lists
      5m 48s
    7. Autofilter
      4m 13s
    8. Designated lists
      2m 28s
  6. 11m 19s
    1. Print options
      5m 51s
    2. Printing and hiding data
      1m 58s
    3. Headers and footers
      3m 30s
  7. 21m 52s
    1. Creating formulas
      6m 30s
    2. Relative and absolute
      6m 1s
    3. External references
      6m 0s
    4. Named constants
      3m 21s
  8. 7m 47s
    1. Functions
      7m 47s
  9. 19m 6s
    1. Fonts and merging
      3m 52s
    2. Rotate and indent
      1m 47s
    3. Borders
      2m 41s
    4. Shading and format painter
      2m 30s
    5. Rename and color worksheet tabs
      1m 52s
    6. Working with pictures
      6m 24s
  10. 11m 31s
    1. Templates
      3m 45s
    2. Styles
      3m 55s
    3. Autoformat
      55s
    4. Smart documents
      2m 56s
  11. 13m 15s
    1. Chart terminology
      2m 23s
    2. Chart wizard
      5m 10s
    3. Formatting charts
      3m 22s
    4. Inserting images
      1m 42s
    5. Printing charts
      38s
  12. 5m 1s
    1. File search
      1m 51s
    2. Find and replace
      3m 10s
  13. 8m 19s
    1. Import from Word
      1m 17s
    2. Delimited data
      2m 53s
    3. Import from the web
      1m 49s
    4. Exporting data
      2m 20s
  14. 7m 54s
    1. Consolidation
      5m 12s
    2. 3D formulas
      2m 42s
  15. 5m 33s
    1. Multiple panes
      1m 12s
    2. More screen options
      4m 21s
  16. 13m 37s
    1. If
      2m 22s
    2. Time
      4m 16s
    3. Date and time
      2m 14s
    4. Lookup
      4m 45s
  17. 6m 55s
    1. Compare text
      3m 27s
    2. Concatenation
      1m 47s
    3. Special characters
      1m 41s
  18. 6m 10s
    1. Pivot tables
      6m 10s
  19. 16m 0s
    1. Recording a macro
      8m 43s
    2. Macro menus
      3m 45s
    3. Global macros
      3m 32s
  20. 11s
    1. Goodbye
      11s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Excel 2003 Essential Training
4h 9m Beginner Mar 18, 2004

Viewers: in countries Watching now:

Excel 2003 Essential Training with Mark Swift is a movie-based workshop for users who are new to working with spreadsheets, or those wanting to improve their skills. This workshop begins with a basic overview of the application and quickly advances to cover useful formulas, functions, techniques for enhancing spreadsheets, charts, and much more. Exercise files accompany the training, allowing you to follow along and learn at your own pace.

Subjects:
Business Spreadsheets
Software:
Excel
Author:
Mark Swift

Recording a macro

macros can be as simple as clicking Record on your VCR and recording actions that you take, then you can take that recorded file and play it back as often as you want to repeat those actions, or you can take that file and assign a shortcut key to it, you can assign it to your own custom menus, or you can drop an icon on the existing toolbar and utilize it any time you want with a simple click. The key to creating effective macros is knowing when to record your actions so that they become as useful as possible. We're going to see that right here. I should also note at this point that recording a macro records a complex VBA script. VBA is Visual Basic for Applications, and it really is a mini development environment that exists within the Office Suite. If you know how to script inside of VBA, you can create macros that really enhance the functionality of any of the applications inside the Office Suite. You can make your Excel spreadsheet look and feel more like a true application than anything else. We're going to stick to the simple record and playback method, which is how most people record macros and provides for more power than most people need anyway. Let's start by adding a row here in our spreadsheet, and in the first cell we'll type our title: QUARTERLY SALES. Now that we have our title created, let's begin recording a macro so that we can format this title, and then then we can do it again and again any time we need to format a title within a spreadsheet. Let's go up to the Tools menu and you'll expand this in case you don't see macro. You'll notice that the Macro's submenu is also where you access your Visual Basic Editor. We're going to click Record New Macro, and when we do we need to make a few choices. First the macro name. Let's call it TitleFormat. Now you can't use any special characters and you can't leave any spaces here. If you don't like having those two words together, put an underscore, but because this is also a filename, spaces are not allowed, and I'm going to use Control+F, and it's asking me where I want to store this macro. I can store this macro in a workbook, in other words it'll stick with this file or I can store it globally in my Personal Macro Workbook. I'm going to stick with the default for right now, and say OK. And you'll notice this small toolbar that's appeared. Now it's not literally recording you like a video recorder, but it is looking for actions and it's going to record each and every action that you take now within your spreadsheet. So let's start by selecting A1 through E1 and using on our toolbar the Merge and Center button.

Now we can bold that and increase the size slightly, and there we have an effective title. Let's stop recording and we've just saved a macro that will allow us to format a title any time we wish. In order to use that macro however, we need to have information set in cell A1, and we want that information to spread from A1 to E1, and that's the limitations because of the way we started recording that macro. Let me show you. If for example, I want a second title, let's insert another row, and I'll put this for 2003. If I simply make A2 my active cell, go up to Tools - Macro and now the Play button beside the word Macros indicates that I can run any of my macros. So I'm going to do that and here we are: TitleFormat, Run, but it didn't affect the cell that I wanted it to. It simply repeated the steps that I had done earlier, and it took the value in A1, which was already centered and merged and increased size and bolded, everything's been done for me. Now that macro will work very well on a new worksheet. If we simply open up a new worksheet, go in and create a title, let me just move away and back, there we go. Tools > Macro, Run your macro.

Notice now that it has a worksheet name attached to it because it's looking externally to the open worksheet to run this macro cause we saved it inside of that worksheet. Run that. Now that worked, but again our title only runs from cell A1 to E1. What if we need to extend it beyond that range or less than the number of columns that we previously recorded. Let me suggest that we do this. I'm just going to move to Sheet2 and here I'm going to play some information already in this cell. I'll call this TITLE2, and before I begin recording my macro, I'm going to select an area, a range. Now I can go up the Tools menu, down to Macro, Record New Macro, and we'll call this TITLE2, and I'll assign a shortcut key. Uh oh, that shortcut key is already in use. See how smart it is.

Well let me give it a new key then. Control+T. Now it's recording a macro. I have a selection already in place, so when I do my merge, bold and title size increase. I'll stop recording. It's working with an existing selection. Let me show you how that changes. Now I'll go to Sheet3, and I'll make TITLE3, and with TITLE3, I only want it to be centered and merged across three columns.

Tools, Macro, and I'm going to play back my macro called TITLE2. Notice that it worked within the selection that I currently set. By recording my macro after the selection was made, I changed the behavior so that I could go ahead and set up my title a little bit and then execute the macro to apply the formatting that I wanted. I can do exactly the same thing in row 4. Remember that the first macro was limited to the first row, because that's where I had recorded it. Now I can set in Subtitle and let me highlight more columns. Go up to Tools, Macro, Play Macro and again it worked beautifully. The selection that I have is the selection that it uses. Before we stop looking at this particular macro, let's look at it behind the scenes. If I go into the Tools > Macro menu, and play macros before I execute a macro, I can look at that macro by going into Edit. Here we're in the VBA Editor and although I don't want you to take away a lot of the coding behind the scene, I would like you to look at the English-like information that is here, to comprehend a little bit of what the macro is doing. For example, the range being specified here is part of the macro. So in the first macro we created our limitation was that it was always working between range A1 and E1. And then with the selection it began modifying our information exactly the way we asked it to, merging and bolding and centering it, making sure that our font size was increased. Let's take a look at the other macro that we created. I'm going to close the VBA Editor, go back to Tools > Macro, and look at TITLE2. We'll just edit that. Here you see that vital step at the beginning where we selected a range is missing. Now it's With Selection apply the following formatting. That's a big difference and it makes it far more versatile from a macro standpoint than our original recording. So keep that in mind, when you begin recording your macro is vital as to how useful that macro, or versatile that macro is going to be in the future. If you're simply doing the same thing over and over and over again, it's not so important, but if you're trying to make a more general application like this formatting macro, it may be key to record it at the right time.

There are currently no FAQs about Excel 2003 Essential Training.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Excel 2003 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.