Using a User Defined Function (UDF) from another workbook using VBA in Microsoft Excel


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


If you liked this blog, share it with your friends on Facebook. Also, you can follow us on Twitter and Facebook.

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

One thought on “Using a User Defined Function (UDF) from another workbook using VBA in Microsoft Excel

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>