Inserting

Adding functions to a code module is very similar to Inserting Subroutines.
This page describes how you can insert an Excel User Defined Function so it can be used in a formula.


Display the Developer Tab

Select the File tab and choose the Options at the bottom.
Choose the Customise Ribbon tab and tick the Developer checkbox.

alt text

Press OK.

alt text

Display the Visual Basic Editor

Press the Visual Basic button (on the left hand side) to display the Visual Basic Editor.
Select (Insert > Module) to insert a new code module.

alt text

You can create a new function by using the (Insert > Procedure) dialog box, or ..

alt text

You can copy and paste a user defined function straight into the code window.

alt text

Any "Public" functions that have been saved in the VBA Project can be called from your Excel formulas.
Select (File > Save) to save these changes.
Switch back to Excel.
You can now access and use this function in exactly the same way you would use a built-in function.

alt text

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext