Cube Root

The cell displays 12, which is indeed the cube root of 1728.

As you might expect, you can use a cell reference as the argument for the CubeRoot function. For example, if cell A1 contains a value, you can enter =CubeRoot(A1). In this case, the function returns the number obtained by calculating the cube root of the value in A1.

You can use this function any number of times in the worksheet. As with Excel's built-in functions, your custom functions also appear in the Insert Function dialog box. Click the Insert Function toolbar button and choose the User Defined category. As shown in Figure 5-6, the Insert Function dialog box lists your very own function.

Figure 5-6:

The CubeRoot function appears in the User Defined category of the Insert Function dialog box.

Figure 5-6:

The CubeRoot function appears in the User Defined category of the Insert Function dialog box.

If you want the Insert Function dialog box to display a description of the function, follow these steps:

1. Choose ToolsOMacroOMacros.

Excel displays the Macro dialog box, but CubeRoot doesn't appear in the list. (CubeRoot is a Function procedure, and this list shows only Sub procedures.) Don't fret.

2. Type the word CubeRoot in the Macro Name box.

3. Click the Options button.

4. Enter a description of the function in the Description box.

5. Close the Macro Options dialog box.

6. Close the Macro dialog box by clicking the Cancel button.

This descriptive text now appears in the Insert Function dialog box.

By now, things may be starting to come together for you. (I wish I had had this book when I was starting out.) You've found out lots about Sub and Function procedures. You start creating macros in Chapter 6, which discusses the ins and outs of developing macros using the Excel macro recorder.

0 0

Responses

  • Kenneth
    How to find cube root of a number in vba?
    1 year ago

Post a comment