Page 319 - Excel Workbook for Dummies
P. 319
33_798452 ch23.qxp 3/13/06 7:51 PM Page 302
302 Part VII: Macros and Visual Basic for Applications
Figure 23-5:
The Visual
Basic Editor
Code
window
after adding
the code
for the
new user-
defined
Commission
function on
its own
module
sheet.
Using a custom function in your spreadsheet
The great thing about custom functions is that they can be inserted into your work-
sheets with your old friend the Insert Function button on the Excel Formula bar. To
find your custom function in the Insert Function dialog box, you just need to select
User Defined as the function category.
Try It
Exercise 23-4: Building Spreadsheet Formulas with a Custom Function
Switch to the Exercise23-3.xls workbook that you opened at the beginning of the last
exercise and then use its RV Sales worksheet to test out your new Commission
custom function:
1. Position the cell cursor in cell E5 in the RV Sales worksheet and then click the
Insert Function button on the Formula Bar.
2. Select User Defined at the very bottom of the Select a Category drop-down list.
The Select a Function list box now displays the name of your custom function as
PERSONAL.XLS!Commission.
3. While PERSONAL.XLS!Commission is selected in the Select a Function list box,
select OK to open the Function Arguments dialog box for the custom Commission
function.
4. While the insertion point is in the TotalSales argument text box, click cell C4 in
the worksheet that contains Fred’s total sales and then press Tab to select the
ItemsSold argument text box below.