To display a form from the Excel application, call the Show() method of the UserForm object in a procedure that can be triggered from Excel (a public procedure in a standard module or an event procedure from an object module). The basic syntax follows:
To Load a form into system memory without displaying it, call VBA's Load() method.
The UserForm object and all of its components can be accessed programmatically after loading it into memory. Note that the Show() method will also load a form if it has not been previously loaded into memory.
For example, the following code displays a UserForm object named frmMessage when the Click() event procedure of a Command Button control named cmdShowForm is triggered. The Command Button control can be placed on a worksheet or another form.
Private Sub cmdShowForm_Click()
frmMessage.Show End Sub
To hide a form from the user but retain programmatic control, call the Hide() method of the UserForm object.
The Hide() method does not remove the UserForm object from system memory, thus the form and its components can still be accessed programmatically. To remove a form from system memory, call VBA's UnLoad() method.
Was this article helpful?