- As part of an expression in VBA Macro Excel procedure.
- In formulas that you create in a worksheet.
Function DiscountPrice(Price as Currency) as Currency
DiscountPrice = Price * 0.95
Here's an example how to use the function in a formula:
And this is an example how to use the function in a VBA Macro Excel procedure:
inputPrice = InputBox("Enter price: ")
MsgBox "New price: " & DiscountPrice(inputPrice)