Table of contents
Collapse the table of content
Expand the table of content

Unload Statement

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Removes an object from memory.



The required object placeholder represents anobject expression that evaluates to an object in the Applies To list. Remarks When an object is unloaded, it's removed from memory and all memory associated with the object is reclaimed. Until it is placed in memory again using the Load statement, a user can't interact with an object, and the object can't be manipulated programmatically.


The following example assumes two UserForms in a program. In UserForm1's Initialize event, UserForm2 is loaded and shown. When the user clicks UserForm2, it is unloaded and UserForm1 appears. When UserForm1 is clicked, it is unloaded in turn.

' This is the Initialize event procedure for UserForm1 
Private Sub UserForm_Initialize() 
 Load UserForm2 
End Sub 
' This is the Click event for UserForm2 
Private Sub UserForm_Click() 
 Unload UserForm2 
End Sub 

' This is the Click event for UserForm1 
Private Sub UserForm_Click() 
 Unload UserForm1 
End Sub
© 2018 Microsoft