Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
After you have identified a certain sequence of actions that you would like to automate in the form of a Macro, it's time to learn how to actually record a Macro. The process has begun already because you've either written down or you know those steps you want to take. For example, we've decided that it's really handy to be able to click on a cell here and when it's questionable, we want to apply a special format. A format that might include using some of the features on the HOME tab like a background of yellow, a red font and a few other features as well, we don't want to go through those steps manually each time.
So, the process of recording a macro also begins with this thought. Is the macro we are about to record, designed only for this workbook or might we want to use it elsewhere? Let's imagine for the moment that we're only going to use this macro in the current workbook. A bit later we might change our minds about that. It is something we need to think about though because certain macros could be used in any workbook. Let's start by going to the VIEW tab in the ribbon. The right most button, Macros has a drop arrow, let's click it, and we see the choice Record Macro.
And here's a dialog box. We need to give our Macro a name. Ideally it should be a meaningful name, the name cannot begin with a number, it cannot contain spaces, some special characters work some don't. It's best to stay away from them. The naming of this macro ideally would be something like Apply Format or Highlight Cells, something like that. How about Highlight Cells, that's an easy one. Now I cannot put a space in but I can use either underscore or maybe I'll simply switch case, either way. So underscore is okay, that's fine, Highlight_Cells.
We can give it a longer name if we wanted too. Macros often have keystroke shortcuts and that's a favorite way, particularly when you're just getting started with this feature. Long term, sometimes you say, well I've got so many macros, I forget which one is which. I don't remember the keystroke shortcut and so on. So at times you might grow weary of this concept. But what can we choose for a shortcut key? We have only 52 choices, any of the lowercase letters, any of the uppercase letters. Now if I think C here for cells sounds like a good idea maybe, but a lot of you now that Ctrl+C, one of the most widely used keystrokes of all in Excel is for Copy.
If we use Ctrl+C for this Macro, we will no longer be able to use Ctrl+C for Copy, so that isn't a good choice. Do you use Ctrl+H, that means Replace, well you might, but if you don't, well you could possibly use that one. There might be a tendency here to use uppercase letters. And all I need to do is hold down the Shift key. So I'm about to use Ctrl+Shift+H. I'm holding down Shift key right now, pressing the letter H. The word Shift pops in automatically. Now earlier, I'd mentioned this idea of using the macro in this workbook only.
If that's the choice we will click the arrow here and choose This Workbook. If you do want a Macro to be available for all workbooks at all times, you store it in a location called Personal Macro Workbook and we'll get to that in a bit. This time we're saying the macro we're writing, at least for awhile, it maybe always will be stored in this workbook. Now there's a description panel here and for small macros, typically we don't say anything, but longer macros, it's really helpful to provide a description.
And you will find it useful yourself when you look a Macro that you wrote last year or a while ago, and certainly others if they happen to be using this macro will want to know what the Macro does. Sometimes the name doesn't do it enough justice. So you can certainly provide a description here. So in this case, the macro is short enough. The macro name itself does a pretty good job of describing it. We're about to click Okay, but before we do, let's talk about what is about to happen. When we click OK, we will be in a mode of recording a series of actions.
And so the idea is we want to stay focused. We should know exactly, what it is we want to do, perhaps we've written down the steps. In a lower left corner of the screen, in the status bar, we see the word READY, but we're about to see something else there as we click OK. Now in the lower left corner, there's a little box next to the word READY. If we slide over it, the pop-up reads A macro is currently recording, click to stop recording. And we can certainly stop the process right there. We can also go back by way of the VIEW tab in the ribbon to the Macros arrow and choose Stop Recording up there as well, but we're in recording mode right now.
So if I'm scrolling up and down here, that's going to be in the macro. It's practically meaningless, we won't see it, but the idea is we don't want to be taking actions here that will be in the macro. Behind-the-scenes, what we don't really need to get into is the fact that every action we take is actually translated into the programming language VBA, Visual Basic for Applications, and learning about that feature takes a good deal of time and requires a different course. In this course, all we need to focus on is the idea that when you turn on the macro recorder, the steps that you are recording can be used later instantly with a keystroke shortcut.
And ultimately maybe even a new button in the Quick Access toolbar. So we're in this recording mode right now, let's apply those features that we want to have happen every time we use this macro in the future. So we go to the HOME tab and we've used this recently, so the yellow is still there, we want to use the fill color yellow, fine. We want to use red font, that's good; we want to make it bold, it's good and let's say we apply the Border feature as well here, the Thick Box Border. Remember we want that to happen every time we run this macro in the future.
And those are all the steps that we need. The question might have entered your mind; will this work if we highlight multiple cells? Well, it will. You don't necessarily know that ahead of time, but it will, and we can use this on one cell or different cells even. So we've essentially recorded all there is to record, and we're done. So we can end this by either going to the box in the lower left corner, that's certainly straightforward. Less straightforward but just to show that it's there, VIEW tab, the arrow for Macros, Stop Recording either way.
So we've recorded this. Let's go to a different location, let's try this Ctrl+Shift+H, it works. Can we try it on a few cells? Again, recognizing the reason we set this up is because we recognize that some of these cells need to be looked into. I think both of those are incorrect. Maybe Ctrl+Shift+H, looks like the feature works on multiple cells as well. So I've seen an example here of how recording a series of actions can easily be executed by pressing that keystroke shortcut.
And you will hear the term Playback, Execute, Run; they all mean the same thing. The idea of making the macro, do what it needs to do with just a single action.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 74709 Viewers
80 Video lessons · 129827 Viewers
52 Video lessons · 64035 Viewers
59 Video lessons · 49823 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.