Use a UDF in an XLA in the VBA code of another workbook

Jubinell

Board Regular
Joined
Jan 17, 2008
Messages
166
Hi,

I've created a UDF which I've stored in an .xla file fired up in Excel and ready use. In fact it works great in the worksheet of any workbook. However when it comes to VBA and I try to use this UDF Excel tells me it can't recognize the function.

How make the UDF universal in both worksheets and VBA codes?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
See
How one VBA project can use an object declared in the class module of another project
http://support.microsoft.com/kb/555159

While the above deals with a class object, the concept is the same as for a function. Treat New_clsEmployee as the function of interest.
 
Upvote 0
I'm not sure I follow. The first instant of New_clsEmployee that I see in the document is this function.

Code:
Option Explicit
Public Function New_clsEmployee() As clsEmployee
    Set New_clsEmployee = New clsEmployee
    End Function

If New_clsEmployee is my UDF, then what is clsEmployee? Do I also need the code a few lines above?

Code:
Option Explicit
Dim sName As String
Property Get Name() As String
    Name = sName
    End Property
Property Let Name(uName As String)
    sName = uName
    End Property
 
Upvote 0
For your work that's not the important part. See how the function is called from the example subroutines.
 
Upvote 0
Umm...not sure if this is what you're trying to get at, but I went to Tools - Reference in the VBA environment and put a tick next to my .xla.

Then I was able to call the function as is. No additional work needed.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top