Flexible Interactive Workbooks in Excel

Tutorial 6

Add show/hide buttons and macros

This is possibly the most difficult stage to follow, but is the most effective part of the Flexcel style. It involves using macros to enable cells to be hidden or shown by clicking on them.

The macros are supplied in the Toolbox, but need cutting and pasting and then slight alteration for your workbook. The macros are then linked to transparent rectangles positioned over the cell to be hidden.

The following steps will work through the stages described above.

  1. Copy the macros

    • Open the Flexcel Toolbox using this link. Click on the 'Visual Basic Editor' button from the Macros toolbar, (fig. 14.). This will open the VB editor.

    • Search for Sub hide_show_cell(cellref, backcol, fontcol) and highlight this and the next Sub's up to Sub open_calc(), (fig. 15.). Copy this code, then in the VBA Project Box, select VBA Project (Conversion), then from the menu, select 'Insert, Module', (fig.16.). Now paste the code you copied. The required macros are now in your workbook.

  2. Ammend the macros

    • Still in the VB editor, starting at Sub hide_show_S4(), change the cell references, (fig. 17.), to the required ones, ("B4", "D4", "C2" and "C5"). Do not change the "A1" reference. Now Close the VB editor.

  3. Place the buttons

    • The buttons used for these macros are simply transparent rectangles. Use the drawing toolbar, (fig. 18.), to draw a rectangle over cell "B4". Now use the 'Fill Colour' button and the 'Line Colour' button, (fig. 19.), from the drawing toolbar to select 'No Fill' and 'No Line'. This makes the rectangle transparent.

    • Right click the rectangle and select 'Assign Macro'. In the 'Macros in' box, select 'this workbook'. Next select the macro hide_show_B4 from the list and click ok. (fig. 20.)

    • Click off the rectangle, then click it again. The cell should now be hidden. Click again and the cell is shown.

    • Repeat this process for the other cells to be hidden.

  4. Add a macro to open the MS calculator

    • Use the 'Button' button from the Forms toolbar to insert a button into the worksheet. Right click the button to assign the macro, then alter the text on the button. (fig. 21.)

    • You could also add arrows or extra text, etc. to complete the look of the worksheet. (fig. 22.)

Now move on to Step 7