I am attempting to pass a predefined array in a Module to a Userform Listbox.
I have assigned the array as a public variable within the UserForm and have attempted to assign it from within the module.
Here is the code for the Module
Sub TestList()
Dim ArrTest As Variant
'Code to populate the array would go here in real application
ArrTest = Array("A", "B", "C")
UserForm1.ListArray = ArrTest
UserForm1.Show
End Sub
And here is the code for the UserForm
Public ListArray As Variant
Private Sub UserForm_Initialize()
ListBox1.List = ListArray
End Sub
When I step through the code, the UserForm opens up when it reaches the ListArray assignment in the module, however within the UserForm the Array is assigned as empty and encounters and encounters Run-time error '381' when it reaches the listbox generation.