Passing In Arguments
It is possible to pass information to a userform however you cannot use the Userform_Initalise event.
The Userform_Initailize event does not allow arguments to be passed to it.
There are a number of different ways you can work around this
Creating a Userform Property
Creating a userform property is the best approach because it means that your code is self-contained (encapsulation principles)
Dim oMyForm As UserForm1
Set oMyForm = New UserForm1
oMyForm.Property_CaptionTitle = "some text"
Private m_sCaptionTitle As String
Property Let Property_CaptionTitle(ByVal sValue As String)
m_sCaptionTitle = sValue
The Activate event fires after the Show method is activated
The Initialise event fires after the userform is loaded, ie when a new userform object is created
Using Tag property
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext