1

I writing macro for excel on VB. There is a structure:

Forms
    Form1
Modules
    Main

In the Form1 I have Button click event

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

In the Main I have procedure Test

Sub Test
GLOBALVAR = "VALUE"
End Sub

How I can implement it? I can't create

Module GlobalVariables

End Module

Due to Excel does not support this construction!

1 Answer 1

1

Add a

Public MyGlobalVariable as String

in the Module1

enter image description here

and it becomes accessible in your userform

enter image description here

Sign up to request clarification or add additional context in comments.

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.