Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
As you continue to use Excel, you'll probably find that you repeat sequences of actions. If you would like to automate those tasks, you can record a macro and run it to save you time and energy later. So in this workbook, what I'm going to do is create a macro that will change the formatting of text in the selected cell so that it goes from 18 pt, which it is now, to 12 pt, and also it will wrap text within the body of that cell. So first thing I'm going to do is record the macro, then I will show you how to run the macro that I just recorded, and after that, I will save the workbook as a macro-enabled file.
So first we need to record the macro, and to do that I'm going to use the controls on the Developer tab of the Ribbon. And before I started this exercise, I went into the Excel Preferences dialog on the Ribbon tab, and I checked the box next to the name of the Developer tab, so it would be visible on the Ribbon. So now that that's there, I can use these controls, and the first thing I'm going to do, like I said, is record a macro, and I'll start with cell B3, because that contains the text I want to change. I'll go to the Visual Basic group, and the name of the programming language in which you're recording is Visual Basic for Applications, and that's why the script is called Visual Basic.
So I'll click the Record button, and Excel displays the Record macro dialog. I can now type in the name of my macro, and I'll call it SmallWrap. That's there, so when I press Enter or click OK, Excel starts recording, and you'll notice that the Record button changed to a stop button. When I'm done with my macro actions, then I can click that, and it will stop. From now on, everything I do until I click stop, will be recorded by the macro recorder, so I do need to be exact.
First thing I'm going to do is go to the Home tab and change the font size to 12. Okay, so that just happened, and then I'm going to wrap the text within the cell, so I click the Wrap Text button and then click Wrap Text. When I do, Excel applies those changes, and that's all I wanted to record, so now I will go back to the Developer tab of the Ribbon. Excel doesn't record when you change tabs on the Ribbon; it only records when you take an action that affects the worksheet. So here I go back, click the Record button, which is now a stop button, and when I do, Excel stops recording the macro.
Now the macro is available for me to run. So I will click cell B5, which contains other text that I can reformat, and then again, on the Developer tab, I open the macros dialog box by clicking the Macros button and make sure that the SmallWrap macro is highlighted. That's the one I want to run, click Run, and Excel runs the macro. Now that I know it's working properly, I can save the file, and the first thing I'm going to do is try to save the file as a regular workbook to generate an error, so you see what it looks like, and then I'll save it in the actual macro-enabled workbook format.
I'll press Command+S to save the file, and when I do, Excel says that macros will be removed if I save the file in this format. Are you sure you want to continue? And also if you want to choose a different file format, click Cancel. That's because there are two separate file types in Excel 2011: macro-enabled workbooks and non macro-enabled workbooks. So I want a macro-enabled workbook; I don't want to lose what I just recorded, so I'll click Cancel and when I do, Excel displays the Save As dialog box. I'm going to choose a different file format, so I'll click the Format down arrow, and here in the Specialty Formats lists, you'll see Excel Macro-Enabled Workbook, and that is what I want.
You can't save a macro in just any regular workbook. You have to distinguish it by telling Excel that yes, I do want this file to have macros enabled. So I'll click that, and everything looks good. I'll click Save, and Excel saves my file. Before you record a macro, you should take the time to plan the steps you're going to perform. You might find that it helps to write down the outline and have it in front of you while you go through those steps.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 70090 Viewers
80 Video lessons · 127451 Viewers
52 Video lessons · 62394 Viewers
59 Video lessons · 48098 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.