0

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
R.T.
  • 1
  • 2
  • Does this answer your question? [Call a VBA Function into a Sub Procedure](https://stackoverflow.com/questions/1072075/call-a-vba-function-into-a-sub-procedure) – TylerH Sep 18 '20 at 14:29
  • No, It describes some of what I've done above, but offers no solution. I don't think it is a programming issue, but rather a setting that's missing, or has been undone. – R.T. Sep 18 '20 at 17:07

1 Answers1

0

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

R.T.
  • 1
  • 2