How to create a user-defined function

If you know Visual Basic programming then you can create your own user-defined functions in Excel. Follow the steps below:

1. On the Tools menu select Macro.

2. On the Macro submenu select Visual Basic Editor.

User defined1

3. You will be switched to Visual Basic Editor Menu.

User defined 2

4. On the Insert menu (Visual Basic Editor) select Module.

5. This will open the code window.

User defined 3

6. Type the Visual Basic code for your function.

7. On the File menu click Close and return to Microsoft Excel.

8. Your new function should now be ready for use like any other Excel function.

Applies to: Excel 2003