Macros for Beginners:
Hello everyone and welcome to the first installment of Alex’s Excel tip o’ the day! You all can also let me know what kind of questions you need answered, and I’ll include them in a future post. If you have a tip to share with the world, send it in . . . I’m not a glory hog. Those of us with mind-boggling cell slinging skills don’t need to be. Just don’t be surprised when I take credit for it.
First, open up a new workbook where we can play. Now is probably a good time to let you know that I’m using the newest version of excel. This means my screenshots will mean absolutely nothing to many of you out there at this time. I apologize for that, but I’m not going to upgrade to a previous version just to make it easier to understand me. Part of being an excel guru is maintaining a certain mystique. Don’t worry, each of you will learn to cultivate this mystique as well. For now, just try to figure it out where to find everything whether you use toolbars or ribbons.
After you have your new spreadsheet, type in some stuff in a random cell. It doesn’t matter what it is, but I typed “goofball” into cell C3 and I’ll be using this in my example going forward. Like just about anyone else, I’ve found myself repeatedly formatting the word goofball as Garamond font bold 18 points with Red background and white font color. So, let’s set it up so I can use a keyboard shortcut to do it all for me.

The dialog box in figure 2 shows up. Here we can make up a name (I used GoofballFormat), assign a keyboard shortcut, give excel some info about where to keep the macro, and add a description. First off, give your macro a name; I suggest making it descriptive in order to make maintaining a lot of macros easier. Second, you may assign a keyboard shortcut. Don’t use something like ctrl+c because that’s copy. Be unique. In order to get the cool Ctrl+Shift+

Here’s where we get to the meat of the macro. Whatever you do from now until you stop recording will go into your macro, so no typing bad names for your boss here, folks. Let’s right click on the cell containing goofball, select format cells from the context menu that appears and pick the following from the dialog box: font bold, Garamond, 18 pt, font color white, fill red. Click Ok. Right-arrow once (just so we have something to remove from our macro later). Next, stop the recorder by clicking the stop recording button as shown in figure 3.

Now let’s take our macro for a test drive. Type “goofball” into cell C6 and press enter. Select cell C6 again and hold ctrl+shift+T all at the same time and . . . woohoo! Your goofball format has been applied!
Notice excel automatically selected a cell way the heck out in Timbuktu? That’s because of the little right-arrow we did at the end of recording our macro. Let’s pop the hood and take a look at the engine in order to get rid of this undesirable behavior.
First, we’re going to open the visual basic editor (figure 4).

In Excel 2007, click the visual basic button in the developer ribbon. In all versions, you can hit Alt+F11 to open the VBA editor. You’ll get the window shown in Figure 5.
