PDA

View Full Version : Reference to different VBAProject



fboehlandt
08-06-2010, 04:25 AM
Hi everyone,
I tried to reference from a different VBAProject but something appears not to be working. I still get function or sub not defined. Here my steps to retrace:
- open the module in my current project (simply named VBAproject) containing the function reference
- Go to Tools, References and then select the relevant project from the scrolldown menu. The project has a unique name VBAMatrix (the bracketed term and name of the actual add-in when using Excel is macro.xla)
- rerun the macro
Again, VBA does not recognize the function reference, although the reference appears directly underneath the module. I assume that one should be able to refer to the function as one would to any other in the same project(i.e. without the application.worksheetfunction prefix). If it helps:
- the functions are recognized in Excel
- the add-in opens automatically whenever I start Excel (hence it is never inactive)
- The relevant function is defined in an Option Private Module
Any ideas please?
__________________

Bob Phillips
08-06-2010, 04:36 AM
I have just tried it and it worked fine.

Can you post the workbooks?

fboehlandt
08-06-2010, 04:44 AM
Ah, here you are again :)
Sorry for using a different forum. I take it you have matrix.xla. Not sure how to post workbooks but I can upload it on my website. Will be a minute or so. In the mean time the sample code:


Option Explicit
Sub principal(MyRow As Integer, MyCol As Integer)
Dim rng As Range
Dim MCorrel As Variant
With roi
Set rng = .Range(.Cells(7, 5), .Cells(7 + MyRow, 5 + MyCol))
MCorrel = MCorr(rng)
End With
With pca
.Range("AG1").Value = MCorrel
End With
Application.Wait (Now + TimeValue("0:00:03"))
Unload aform_filepath
Unload aform_enterN
Unload aform_enterO
Unload aform_calendar
Unload aform_progress
End Sub


The error occurs when referring to MCorr which is one of the package functions. Will get back to you with link to workbook. Thanks

fboehlandt
08-06-2010, 04:50 AM
http://www.carmenmiranda.de/pages/excel-download.php
here we go. The relevant macro is contained in Mod_pca. Any ideas?

Bob Phillips
08-06-2010, 04:50 AM
You can post it here, click GO Advanced, and there is a Manage Attachments button.

Bob Phillips
08-06-2010, 04:53 AM
I don't have matrix.xla

fboehlandt
08-06-2010, 06:22 AM
here we go. Option Private statement in source project. Changed to Public and it works. Thanks for the help