## How to write a custom function in excel 2007 ### Watch the Video

To create a function, open a new Excel workbook and create a small worksheet as shown in the image to the right: I'll show you how to create a custom function to calculate the selling price of an item using the following formula: selling price - cost price * (1+markup percentage) To make this calculation in cell D4 of the example worksheet (given the markup percentage is 50%) you would write this formula . Make sure you are working in a macro-enabled workbook (one of the Excel file types). Follow along to create custom functions: Press Alt + F This gets you to the Visual Basic Editor, where VBA is written. You can also click the Visual Basic button on the Developer tab of the Ribbon. To create a custom DISCOUNT function in this workbook, follow these steps: Press Alt+F11 to open the Visual Basic Editor (on the Mac, press FN+ALT+F11), and then click Insert > Module. A new module window appears on the right-hand side of the Visual Basic Editor. ### How to Create a Custom User Defined Function

To create a function, open a new Excel workbook and create a small worksheet as shown in the image to the right: I'll show you how to create a custom function to calculate the selling price of an item using the following formula: selling price - cost price * (1+markup percentage) To make this calculation in cell D4 of the example worksheet (given the markup percentage is 50%) you would write this formula . The designers of Excel couldn’t possibly anticipate every calculation need of every user. So instead, Excel provides you with the ability to create custom functions, which are explained in this article. Creating a Simple Custom Function. Custom functions, like macros, use the Visual Basic for Applications (VBA) programming. 22 rows · 6/01/ · The Newton-Raphson custom function described in a previous section was . To create a function, open a new Excel workbook and create a small worksheet as shown in the image to the right: I'll show you how to create a custom function to calculate the selling price of an item using the following formula: selling price - cost price * (1+markup percentage) To make this calculation in cell D4 of the example worksheet (given the markup percentage is 50%) you would write this formula . Excel allows you to create custom functions using VBA, called "User Defined Functions" (UDFs) that can be used the same way you would use SUM() or other built-in Excel functions. They can be especially useful for advanced mathematics or special text manipulation or date calculations prior to Make sure you are working in a macro-enabled workbook (one of the Excel file types). Follow along to create custom functions: Press Alt + F This gets you to the Visual Basic Editor, where VBA is written. You can also click the Visual Basic button on the Developer tab of the Ribbon.  