I have something like this:
Private Sub ComboBox1_Change()
'(...do something related to alpha...)
End Sub
Private Sub UserForm_Activate()
Set alpha = CreateObject("Scripting.Dictionary")
'(...do something like add keys and values to the alpha dictionary...)
End Sub
I'm really new at VBA and I noticed that alpha
dictionary can only be used inside UserForm_Activate
, so I want to make a global variable in order to use it also in ComboBox1_Change
.
But I can't.
I tried with something more simple, like an integer.
Public x as Integer
Private Sub ComboBox1_Change()
MsgBox(x)
End Sub
Private Sub UserForm_Activate()
x = 5
End Sub
And this work, but if I do something similar but with a dictionary (Public alpha as Scripting.Dictionary
), it raise (from spanish) "Compilation error: It wasn't defined the type defined by the user". I don't know what to do.