USING CUSTOM FUNCTIONS

Now you’re ready to use the new Discount function. Press Alt+F11 to switch back to the worksheet. Select cell F9 and enter =Discount(C9,D9). Excel calculates the 10 percent discount on 200 units at $47.50 per unit and returns $950.00.

In the first line of your VBA code, Function Discount(quantity, price), you indicated that the Discount function would require two arguments, quantity and price. When you call the function in a worksheet cell, you must include those two arguments.

In the formula =Discount(C9,D9), C9 is the quantity argument, and D9 is the price argument. Now you can copy the discount formula into F10:F15 to get the discount amounts in the worksheet.