简体   繁体   English

使用 Excel VBA 中的按钮执行多个模块

[英]Executing multiple modules using a button in Excel VBA

I am trying to execute two module sub in excel VBA through a third module, through a button.我试图通过第三个模块,通过一个按钮在 excel VBA 中执行两个模块子。

The subs are defined in unique module files as: subs 在唯一的模块文件中定义为:

Public Sub MinPenCheck()

'code here, if statements, variables etc. 

End Sub

And:和:

Public Sub InputCheck()

'code here, if statements, variables etc. 

End Sub

I defined a third module as follows:我定义了第三个模块如下:

Public Sub DesignCheck()
   Call InputCheck 'Macro1
   Call MinPenCheck 'Macro2
End Sub

And I inputed a button in my spreadsheet, assigning the above macro to it.我在电子表格中输入了一个按钮,将上面的宏分配给它。 When I press the button, the other two modules are not executing.当我按下按钮时,其他两个模块没有执行。 I am getting the error "Expected variable or procedure, not module".我收到错误“预期的变量或过程,而不是模块”。

How can I achieve this?我怎样才能做到这一点?

Correct is正确的是

Public Sub DesignCheck()
   Call InputCheck.InputCheck() 'Macro1
   Call MinPenCheck.MinPenCheck() 'Macro2
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM