0

How do I explain the 'expected variable or procedure, not module' error in this instance?

Code:

Routine -

Sub WTS_9_Click()
    Call Module1
End Sub

Module -

Sub Rec_9_Click()

The error came about because I learnt a better way to structure code by calling in sub-routines through modules. I have activated the Solver, carefully renamed Modules - set variables, functions and other objects are not interfering - and, yet, it remains stuck. Ideas to help explain the jam would be appreciated.

2 Answers 2

1

You dont Call a module, you Call the routine, and the word Call is optional.

You probably want this:

Sub WTS_9_Click()
    Rec_9_Click
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Ah, yes, OK, calling passes through the module. Gotchya.
1

Within you module you need to declare (public) routines, i.e.

Module (named Test)

Public Sub TestMessage()
    MsgBox "Test"
End Sub

Then in your code (i.e. events) you can call this routine within the module:

Sub Button_Click()
    call TestMessage
    call Test.TestMessage ' you can skip the module name if routine name is unique
End Sub

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.