
Name_________________________ Pawprint _______________ Section _____
Written Macro Assignment Solution
1. Open up Excel. Go to Cell B7 and name this cell “Pumpkin”. Then go to the Developer
tab on the Ribbon, and click on the Record Macro button in the Code group. Name your
macro “Referencing” and give it a shortcut key of “R”. After clicking OK to close the
Record Macro dialog box, do the following:
Select Cell A3 using absolute referencing (do not select the Use Relative
Reference button).
Using the drop-down arrow to the right of the Name Box, select “Pumpkin”.
Click on the Use Relative Reference button in the Code group on the
Developer tab to use relative referencing, and then select Cell C1.
Click on the Stop Recording button on the Code group on the Developer tab.
After you have performed these steps, view your code in Visual Basic Editor, and answer
the following questions:
a. What code was written when you selected Cell A3 using absolute referencing?
Range(“A3”).Select
b. What code was written when you selected the cell named “Pumpkin” using the
Name Box drop-down menu?
Application.Goto Reference:="Pumpkin"
c. What code was written when you selected Cell C1 using relative referencing?
ActiveCell.Offset(-6, 1).Range("A1").Select
Remember that ActiveCell.Select is the basic format used when writing macro
code using relative referencing. Also, please note that when writing out the VBA
code to move from one cell to another using relative referencing (as we did
above) the Range(“A1”) portion of the code is not necessary. It shows up
automatically (as displayed above) when we are recording a macro and moving
from one cell to the next using relative referencing, but if you are just writing out
the macro code, you do not need to include that portion of the code.
2. Cell B3 is the current cell you are in on your Excel spreadsheet. Write the appropriate
VBA code to perform the following:
a. Move from Cell B3 to Cell A9 using relative referencing
ActiveCell.Offset(6,-1).Select
Note that I did not include Range(“A1”) before .Select, as this is not necessary
(see my note above).
1