Reputation: 1595
I imported a module (.bas
) into my excel project.
However, when I click on the button Run
, Excel ask me the macro name and even if I put the name of my macro, this is not working because the Execute
button is disabled.
Someone can help me to fix it please ?
Thanks in advance.
EDIT 1
The macro name is : Sub calcul(heureOuverture As String, heureFermeture As String)
If I don't use parameters this is working...
Upvotes: 0
Views: 347
Reputation: 333
A sub-procedure (Macro) with parameters cannot run directly. It must be called from another macro with required parameter. You may do it like this:
Sub CallerMacro()
'calcul "heureOuverture value", "heureFermeture value"
Call calcul("heureOuverture value", "heureFermeture value")
End Sub
Upvotes: 0
Reputation: 2395
1) Compile your project. This can be done by Debug > Compile VBA Project
2) Use Option Explicit
at the top of each module.
3) Before you run the macro use the Break
(CTRL + Break) and the Rest buttons to ensure clean slate.
4) If you need to pass arguments to a routine you cannot use the Run Sub/Userform (F5) from the VBE as you will need to stipulate the arguments. As such, you can consider something like the below:
Sub TestCall()
Call calcul("myStr1","myStr2")
End Sub
Upvotes: 1