SUMMARY
To compute the factorial of a number in versions 1.50, 2.20, or 3.00
of Microsoft Excel, the FACT function can be used.
To create a function that will compute factorials in versions 1.06 and
earlier of Excel, do the following:
- Enter the following commands into a macro sheet:
+---+-------------------------------------------------------+
| | A |
+---+-------------------------------------------------------+
| 1 | Factorial |
+---+-------------------------------------------------------+
| 2 | =RESULT(1) |
+---+-------------------------------------------------------+
| 3 | =ARGUMENT("number",1) |
+---+-------------------------------------------------------+
| 4 | =SET.NAME("factorial.result",1) |
+---+-------------------------------------------------------+
| 5 | =IF(NOT(number>1),RETURN(factorial.result)) |
+---+-------------------------------------------------------+
| 6 | =SET.NAME("factorial.result",factorial.result*number) |
+---+-------------------------------------------------------+
| 7 | =SET.NAME("number",number-1) |
+---+-------------------------------------------------------+
| 8 | =GOTO(A5) |
+---+-------------------------------------------------------+
- Select cell A1.
- From the Formula menu, choose Define Name.
- Under Macro, select Function.
- Click OK.
To use the function macro in a worksheet, do the following:
- Make sure the macro sheet is open.
- Select the cell to contain the function.
- From the Formula menu, choose Paste Function.
- Scroll to the bottom of the list of functions.
- Select the desired function [which will be of the form
MacroSheetName!Factorial()] and click OK.
- Enter the number to be factored between the parentheses and press
RETURN.
|