1016 Chapter 40
Note For the purposes of this exercise a formula is anything beginning with =, and
a number is anything beginning with the characters 0 to 9.
5. Rewrite the macro in exercise 4 so that it uses another method (the correct one) to
detect the existence of a formula in a cell. Look at the different properties of the
Range object in the Help fi le.
6. The annotations for worksheet formulas in this book were done with a macro. For
example, running the macro on this worksheet, in which the active cell is A2,
1
2
AB
3
3
4
1
2
4
produces the following worksheet:
1
1
2
3
AB
2<
--
=A1+1
3
4
4
Notice the changed column width. Write a macro to perform the annotation. If the
cell immediately to the right of the active cell is not empty, the macro should over-
write it only after receiving confi rmation from the user.
7. The Selection object represents the current selection in the worksheet. Selection is
usually, and for our purposes always, a Range object. Rewrite the macro in exercise
6 so that it works on a selected range.
Note the following:
•
If the selected range is a single cell, activate the macro in exercise 6.
•
If the selected range is a row range, the annotations should go below the selected
range.
•
If the selected range is more than one column or one row, the macro should abort
with an appropriate message.
8. Array functions are functions that return more than one value. For example, the
Transpose worksheet function returns its argument turned by 90 degrees, as the
following worksheet demonstrates: