Home » excel » excel – VBA – "Call" cannot find the Sub or Function

excel – VBA – "Call" cannot find the Sub or Function

Posted by: admin April 23, 2020 Leave a comment

Questions:

I created the following MACRO:

    Sub X()
        Call Y
        Range("A1:M31").Calculate
    End Sub

Y is defined as Public in another module:

    Public Sub Y()
        Cells(13, 13) = A()
        Cells(14, 13) = B()
    End Sub

Y, when invoked (via button or after some events) works perfectly and ivokes A and B, which are other Macros defined in the same module as Y.
However, when I try to invoke it from the other module where X is, I get the compilation error: “Sub or Function not defined”.

Where is the problem?

How to&Answers:

Moved the code to a separate module and it worked.