Excelmacros中的Visual Basic全局variables

我写的macros在VB的excel。 有一个结构:

Forms Form1 Modules Main 

在Form1中,我有Button单击事件

 Public Sub CommandButton1_Click() MsgBox GLOBALVAR 'I need access to GLOBALVAR here End Sub 

在主要我有程序testing

 Sub Test GLOBALVAR = "VALUE" End Sub 

我如何实现它? 我无法创build

 Module GlobalVariables End Module 

由于Excel不支持这种构造!

添加一个

Public MyGlobalVariable as String

Module1

在这里输入图像说明

它可以在你的用户表单中访问

在这里输入图像说明