In this article, we will see how to use a User Defined Function (UDF) defined in another workbook.
For this example, we have created a UDF “ReverseText” in “Reversing Characters In String.xlsm” workbook.
Raw data consists of sample text data in “MainFile”.
We want to reverse the sample text using the UDF “ReverseText” from “Reversing Characters In String.xlsm”.
We can use a User Defined Function (UDF) from another workbook like this:
To use the UDF “ReverseText” in “MainFile”, we also have to define the full file name, along with an extension followed by an exclamation mark (!) in front of the UDF. So the Function will be like this:
=’Reversing Characters In String.xlsm’!ReverseText(C11)
Note: If name of the file containing the UDF features space characters then we should enclose the file name within single quotes (‘).
We can also convert the file containing the User Defined Function to Add In. Then add that Add In with the Excel Application.
To create Add In and use Add In, Go to Question 1
Please follow below for the code
'Code in other workbook Option Explicit Function ReverseText(text As String) As String 'Reversing the text ReverseText = StrReverse(text) End Function
We would love to hear from you, do let us know how we can improve our work and make it better for you. Write to us at email@example.com
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.