11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3. Type the name of your function in the Macro Name box.<br />

Chapter 23: Function Procedure Basics 621<br />

Make sure that you spell it correctly.<br />

4. Click the Options button to display the Macro Options dialog box.<br />

If the Options button is not enabled, you probably spelled the function’s name incorrectly.<br />

5. Type the function description in the Description box (see Figure 23-4).<br />

The Shortcut key field is irrelevant for functions.<br />

Figure 23-4: Provide a function description in the Macro Options dialog box.<br />

6. Click OK and then click Cancel.<br />

Specifying a function category<br />

Oddly, Excel does not provide a direct way to assign a custom function to a particular function<br />

category. If you want your custom function to appear in a function category other than User<br />

Defined, you need to execute some VBA code in order to do so. Assigning a function to a category<br />

also causes it to appear in the drop-down controls in the <strong>Formula</strong>s➜Function Library group.<br />

For example, assume that you’ve created a custom function named REMOVESPACES, and you’d<br />

like this function to appear in the Text category (that is, Category 7) in the Insert Function dialog<br />

box. To accomplish this, you need to execute the following VBA statement:<br />

Application.MacroOptions Macro:=”REMOVESPACES”, Category:=7<br />

One way to execute this statement is to use the Immediate window in the VB Editor. If the<br />

Immediate window is not visible, choose View➜Immediate Window (or press Ctrl+G). Figure 23-5<br />

shows an example. Just type the statement and press Enter. Then save the workbook, and the<br />

category assignment is also stored in the workbook. Therefore, this statement needs to be executed<br />

only one time. In other words, it is not necessary to assign the function to a new category<br />

every time the workbook is opened.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!