How to create user-defined functions in Excel

 Excel allows users to create custom functions. This enables user to extend the functionalities of Excel. In the below example, a Boolean function created to accepts a cell as a parameter and returns TRUE if the cell has color FALSE if the cell doesn't have any color. 

Let us call this function IsColor. Open VBA editor, insert a new module and paste the below code into a module.





This will create a new function IsColor. Now, you will be able to use this formula in excel sheet. In the below example cell G5 and G7 are filled with color and G6 and G8 are blank cells. Enter the formula "=IsColor(G5)" and copy the formula down through H8. 


IsColor returns TRUE for G5 and G7 and FALSE for G6 and G8.





Share:

0 comments:

Post a Comment