BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
If you've written a killer function, you'll want to be able to share it between workbooks. The best way to do this is using an add-in.
- Sharing Code across Workbooks using Add-Ins
- Useful Examples of Code to Share
- Creating an Add-In
- Using Add-In Functions (this blog)
Posted by Andy Brown on 05 March 2012
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Using Add-In Functions
The previous parts of this blog show you how to create add-ins; it's time now to use them. To do this, you must link to the add-in.
Using Add-In Functions in Excel
To add a reference for an add-in that you've created, show the Excel options dialog box:
|Using Excel 2010||Using Excel 2007|
You can now go to the Add-Ins dialog box:
To show the Add-Ins dialog box:
In Excel 2010 you can also click on the Add-Ins tool on the Developer tab of the ribbon.
You can now choose the add-in(s) that you want to load:
Tick each add-in that you want to load (here we've ticked WiseOwlCode).
You can now use any of the functions in your add-in within any Excel workbook (this will be true even after you exit Excel and go back in):
Here we've used functions to return people's full names, the path to where files are stored and whether particular worksheets exist or not.
Using the Function Wizard to Include Functions
You'll find it easier to get at functions if you use the function wizard:
Click on this tool to insert a function.
You can then select the User Defined category (as shown here) to display a list of all the functions in your add-in:
When you choose User Defined, you can see the functions you've written and shared.
Using Add-In Functions and Procedures in VBA
To use a function in an add-in, first include the add-in in Excel (as shown above) , then reference it:
We're writing a module in a new workbook, and our DoesWorksheetExist function doesn't seem to exist.
First go into the References dialog box:
Select Tools --> References from the menu in the VBA code editor.
Now tick the box next to the add-in whose code you want to use:
Tick (in this case) the WiseOwlCode application.
You can now use any code in your referenced add-in:
That's more like it! The DoesWorksheetExist function is in a referenced application.
I'd recommend qualifying the function name with the object library to which it belongs:
If you type in the name of the add-in project, the code completes automatically.