Microsoft Office Tutorials and References
In Depth Information
What We’ve Done
worksheet for that matter—and you then run the macro, the logo will nevertheless return
to cells A1:A3. And that’s usually just what you want.
But sometimes you want a macro to start up in a cell that depends on where the cell
pointer is currently situated. Consider this follow-up example: because your worksheets
exhibit various layouts, there may be times when you want to place your logo in different
areas on the worksheet—that is, different ranges. As a result, you’ll want a macro that
will let you click in the first cell in which you want the logo to appear and have it enter
the logo starting right with that cell, rather than automatically making its way back to cell
A1. If you click in cell G3, you’ll want the macro to inscribe the logo in G3:G5. Zoom
over to R13 instead, and the macro will deliver the logo to R13:R15—in other words, in
whatever cell you’ve started the process.
In order to give your macro this sort of
flexibility, you need to work with the Use
Relative References feature (shown in
Figure 11–10).
Figure 11–10. Where to find the Use Relative
References option
Take a close look at the caption accompanying the Use Relative References selection. What
it’s telling you is that this macro option maneuvers the cell pointer (called the cursor in
the caption) to cells relative to wherever you’ve started the macro. Thus, if you record a
relative-reference macro in A1 and then click in A3, when you play it back the macro will
always move two cells to the right of whatever cell you’ve started in.
Thus, in our case, where we want to be able to post our logo in whichever cell we’ve
clicked, we need to use the Use Relative References option. Let’s try it.
1.
First, click in any cell on the worksheet—again, any cell, because the
macro we’re about to record will execute starting in any cell in which we
click, because of relative referencing.
2.
Then activate Use Relative References by clicking View, clicking the
Macros drop-down arrow, and choosing Use Relative References.
3.
Then enter macro-recording mode precisely as before, by clicking View
Macros (drop-down arrow) Record Macro.
Name the macro (say, Logo2 ) in the resulting Record Macro dialog box,
click OK, and type the logo information as per our first macro.
4.
5.
Click the stop-recording button, and you’re done.
Search JabSto ::




Custom Search