Flexible Interactive Workbooks in Excel

Tutorial 7

Record and add rounding macros

The easiest way to create your own macros is to record them rather than code them.

It would be useful in this workbook to have the option of rounding the converted value. It is easy to do this using 'Format, Cells, Number, Number' from the menu. If you are recording a macro as you do this, you can repeat this process again and again using the macro. You can then attach this macro to a button.

The following steps will work through the stages described above.

  1. Record macros

    • Click on the 'Record Macro' button from the Macros toolbar, (fig. 23.). Type in the name for the macro, e.g. round_2dp (spaces cannot be used), (fig 24.). Click ok.

    • Now select cell "D4", (as there is a button on top of this cell, click the cell below followed by the up arrow to select it). Next select 'Format, Cells, Number, Number' from the menu and choose 2 d.p. (fig. 25.). Next select cell "A1", then click the stop recording button.

    • Repeat this process for rounding to 0 d.p. and then no rounding, (general format).

  2. Place a button

    • Almost any object can be used as a button for a macro. You have seen actual 'button's' and transparent rectangles used so far. Try using an 'AutoShape' or a 'Text Box' from the Drawing toolbar. Just right click the object and choose 'Assign macro', then select the macro you require. Attach the three macros you recorded to different buttons. You now have your finished workbook, (fig. 26.).