Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Creating your favorite macros and attaching them to buttons

In previous editions of our books, where everything was geared to Excel 2003 or earlier, I provided a
handout on how to create macros and then attach them to buttons on your own personal toolbar.
Specifically, I showed how to create macros to put the colored borders around input cells, changing
cells, and target cells that we used in our examples.

As you probably know, with the fixed ribbons in Excel 2007, it is no longer possible to create your own
toolbars (well, at least not without advanced programming). This is one reason we decided to change
from colored borders to colored backgrounds for input cells, changing cells, and target cells. You don’t
need macros for colored backgrounds. You can simply click on the color palette on the Home ribbon.

Still, you might want buttons to run your favorite macros, for colored borders or other common tasks.
This is still possible, but only with Excel’s Quick Access Toolbar (QAT) up at the top of the screen. This is
the only part of the user interface that is somewhat customizable. Here’s how to do it.

1. Make sure the Developer tab is visible. If it isn’t, click on the Office button, then on Excel Options,
and check the third checkbox in the Popular group.
2. Now record a macro that does some simple task like create a colored border around a range. To do
so, click on Record Macro from the Developer ribbon. In the resulting dialog box, give the macro a
meaningful name, like RedBorder, and select to store it in Personal Macro Workbook. (With this
option, it will always be available.) Then perform the task (e.g., put a red border around a
preselected range), and finally click on the Stop Recording button on the Developer tab. Of course, if
you know VBA, you could instead write your macro rather than record it, or you could tweak
recorded code.
3. To run your macro from a button, click on the dropdown next to the QAT and select More
Commands. In the Choose Commands From dropdown, select Macros. Select your macro and click
on the Add >> button to move it to the right, i.e., to the list of commands on your QAT. From the
right pane, you can now move your macro up or down in the list. Also, if you select it in the right
pane and click on Modify, you can select an icon for it.

By the way, suppose you’d like more icons than those that are available, or suppose you’d like to “draw”
your own. Or suppose you’d like to customize your ribbons in some way. From what I’ve read, you’re
pretty much out of luck unless you want to check out the much more advanced RibbonX technology.

You might also like