Creating custom functions
Between the built-in functions and the worksheet functions, it is difficult to imagine that you would need anything more. It does, however, sometimes happen that you need something specific. Custom functions are exactly what the name says; they're customized for your specific needs. You develop this function yourself by using VBA.
This recipe will take you through the steps of creating a custom function.
Getting ready
Functions.xlsm
is still open in Sheet1. As always, press Alt + F11 to activate the VBA Editor, and insert another new module.
How to do it…
The first thing about custom functions is that they must be defined in the workbook where they will be used. This makes sense because you won't find them among the built-in functions or the worksheet functions.
Imagine you have to repeatedly – but at intervals and in different places on a worksheet – calculate the number of days between two dates. Of course...