Call a VBA module

Solved
dubolg -  
 dubol -
Hello,

Small programming issue.

I wrote a code in a module (Sub ex1 () )

I want to call the "Sub ex1" in another module (Sub_principal) and have it execute only once

Can you help me? Thank you

Have a nice day

8 answers

chossette9 Posted messages 6855 Registration date   Status Contributor Last intervention   1 313
 
Hello,

you just need to write ex1 or Call ex1 in the main routine.

Example:
Sub Sub_principal() ... Call ex1 ... End Sub


Best regards.
--
This guy wasn't the brightest, as he was naive.
7
cousinhub29 Posted messages 1112 Registration date   Status Member Last intervention   383
 
Good evening;

Would you happen to have a module name called "ex1", by any chance?

You can't name a Sub and a Module the same name....

Have a good evening.
3
dubol
 
Hello,

To present my problem that is still not resolved.

In Microsoft Visual Basic under Excel,

I created 3 macros (starting with Sub... and ending with End Sub) in the module folder. In this same folder, I created a 4th one that I will call main, in which I would like to call the 3 macros (to execute them).

Thank you for your help.
1
pijaku Posted messages 13513 Registration date   Status Moderator Last intervention   2 772
 
Hello,
If your VBA code is not "top-secret", I invite you, for a definitive and quick solution, to copy/paste the codes of the three procedures (I created 3 macros starting with Sub... and ending with End Sub) right here in a response. You'll see, you'll have your solution by the end of the day...
0
dubol
 
It's not the content that matters, but the way of calling the procedures.

I'm on the path to resolution, I'll keep you updated.
0
dubol
 
In fact, I have in the module properties (name) named the same name as the one in the module at the Sub level...

Since I changed to different names, I can now call my procedures.
1
dubol
 
Marked as resolved, THANK YOU
1
dubolg
 
I already tried, the other problem is that it tells me "variable or procedure expected, not module".
0
Le Pingou Posted messages 12273 Registration date   Status Contributor Last intervention   1 476
 
Hello,
Just passing by, at what time did you receive this message?
--
Regards.
The Penguin
0
dubolg
 
It's when I run my program (sub main()) in step-by-step mode.

Shouldn't the variables of sub ex1() be declared in the main?
0
Le Pingou Posted messages 12273 Registration date   Status Contributor Last intervention   1 476
 
Hello,
If at the beginning of the module you have the instruction line [Option Explicit], you must declare the variables.
Regards.
The Penguin
0