Excel 2010 Tutorial - Macros
In this video from the Excel 2010 Tutorial series, School of Technology Program Coordinator, Justin Denton, teaches us all about macros in Microsoft Excel 2010. This tutorial video is a great beginning step to your courses in technology at Rasmussen College.
So the next one we're going to get into is macros. I'll show you the quick and easy for macros. There's a really hard aspect to macros, and I'll lightly touch on that.
So I want to create a macro. On the View tab, we've got that hidden macros button that a lot of people didn't like to touch. You can go ahead and touch it.
We'll use the Record Macro button. It's really the simplest and easiest way, especially if you're working with macros. You need to build a basic macro first. And sometimes it's easier just to record some of the basic routines and then go back in and modify them.
So in this instance, I'm going to record it. So I hit record. We'll call it Macro1. That's fine. And then it's basically-- at this point, it's like a movie. It's recording everything I'm doing.
So I'll right click. I'll delete this column. I'll delete this column. Maybe I want to move-- cut this column. Paste it over here. I don't need an ID column. So, hold on, let me delete this too. I don't need this blank column. And let's say I'm done.
So I just wanted to make some quick reports. So I pulled in that data feed. I wanted to clean it up a little bit. I cleaned it up to the way I wanted it to look like. So after I've done that, now I can hit Stop Recording. So it's recorded everything that I just did. And as it did it, it just saved all that. So now I can undo all those. There we go. Have that same report. I just pulled in that new data feed. I've got my macro already built.
So I'm going to view my macros. I'll select that one that I created and hit Run. And I'm done. And it'll automatically format it all for me. So I never have to go back through all the process of cleaning up the columns anymore. I do it the one time and then forget about it. Because every time I pull in my data feed, I can just hit the record button. It's a really quick and easy way to say, OK, I know macros. I recorded a macro.
There's the more in-depth piece. And what you'll need to do when you go to get into the more in-depth piece. By default, they don't allow the developers tab in Microsoft Excel. To enable that, you actually have to click on File and Options. Customize Ribbon. And then you'll have this option here for Developers Tab. You have to select that. And that'll give you this whole set of really cool tools that'll make you nervous to mess around with.
So if I select that tool. I hit OK. And now I have this new Developer tab that just appeared. In here, it's got the same Record Macros option. But there's all these other features in here that you can work with. What we'll do is we'll just work with the macro that we created.
So if I go into macros, I've got the macro I created. I want to edit it. And this is the thing that-- there's entire classes on this piece because there's so much you can modify. This is actually Visual Basic for application programming language. So everything that we recorded, it wrote the code for automatically. So that's why, if you already know the process, you can automatically record everything.
In here, you're going to go through and modify this a little bit. Maybe I don't want to select this column. Or maybe I don't want to-- where it says Cut Copy mode, false. Maybe I don't want to use this whole section. Now, you'll see where it says selection.delete, shift to the left. So what it does, in this selection, it cut the column and shifted it to the left. It makes a little bit of sense when you actually start looking at it.
Well, you have the ability to add to this too. So if I want to add maybe a message box, I'm going to do message box. And it's just the normal hello world thing. Hello world. I want to add that into my macro. So I'll close out. And I'll click Run. So now it'll tell me hello world, or you're about to run the macro, or something. I'll hit OK, and then it'll run the macro.
There's input boxes and all this other stuff you can start working with. But the general-- I wanted to make sure that we kind of go through this really quick. But that's the general gist of doing macros. There's some sample code in the spreadsheet. There's also some websites at the last page that'll give you additional information about all the different types of Visual Basic application code. But if I go too much in it, then it'll be too much. And then that's all you'll want to do is program, right?