What's the difference between using Initialize
and Activate
as a userForm's boot routine?
Private Sub UserForm_Initialize()
Private Sub UserForm_Activate()
What's the difference between using Initialize
and Activate
as a userForm's boot routine?
Private Sub UserForm_Initialize()
Private Sub UserForm_Activate()
Initalize occurs only once in the form's entire execution so you can use, for example, to add items to a combo box, that is, to place codes that only need to be executed once before the form appears for the user. In the case of Activate, suppose you have to do a validation every time the form is activated, in which case you would use Activate since it always runs when the form is activated
Initialize occurs when the object (in your case the Form) is created . So the code runs only once . Activate occurs every time the form's Activate event occurs, that is, when it receives focus, or when it is displayed after it has been hidden, or any event that activates the object.