Reputation: 1
I can't use functions from another workbook in VBA.
I've created a personal sheet: 'Personal_Functions.xlam' with personal functions located in: C:\Users\UserID\AppData\Roaming\Microsoft\Excel\XLSTART.
Always starts up automatically when opening Excel-file
I'm able to use these UDFs straightforward in any of my workbooks.
=fctTest(1, 5)
which returns 6
However, I'm unable to call them in code:
Compile error: Sub or Function not defined.
I tried adding the *.xlam to the reference but received an error.
Name conflicts with existing module, project or object library
I also tried making a complete new empty *.xlam, and got the same error.
Is it not possible, or do I have to call them in a different way?
Example Coding that does not work:
Personal_Functions.xlam > Module1
Public Function fctTest(in1 As Integer, in2 As Integer)
fctTest = in1 + in2
End Function
Book1.xlsm > ModuleTest
Private Sub subTest1()
Dim test As Integer
test = fctTest(1, 5)
End Sub
Upvotes: 0
Views: 1467
Reputation: 1
Everything i described were the correct steps. But the project names were the same: "VBAProject". To change them:
• View -> Project explorer. Be sure it is on.
• Select your project -> F4 -> Rename
• Tools > References > Browse > All files (.) > Add file
My quest was ended by this link: www excelforum com
Upvotes: 0