Creating a Simple Custom Function

Suppose your company offers a quantity discount of 10 percent on the sale of a product when an order is for 100 units or more. In the following paragraphs, you’ll build a function to calculate this discount.

The worksheet in Figure 28-1 shows an order form that lists each item, the quantity, the price, the discount (if any), and the resulting extended price.

Note

You’ll find the TreeOrders.xlsm file with the other examples on the companion Web site. You can use this file for reference or to practice creating your own custom functions.

In column F, we want to calculate the discount for each item ordered.

Figure 28-1. In column F, we want to calculate the discount for each item ordered. ...

Get Microsoft® Excel® 2010 Inside Out now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.