Hi everyone,
I have a bunch of forms in memory as part of UserForms collocation. I find the particular form that I want to unload from memory through a "for each" loop, but I fail to do so successfully.
Could anyone suggest a correct syntax?
Many thanks in advance
I have a bunch of forms in memory as part of UserForms collocation. I find the particular form that I want to unload from memory through a "for each" loop, but I fail to do so successfully.
Could anyone suggest a correct syntax?
Many thanks in advance
Code:
Public myForm As UserForm
Sub UnloadForm()
Dim ctrlLabel As MSForms.Control
For Each myForm In UserForms
On Error Resume Next
Set ctrlLabel = myForm.myLabel
If Not ctrlLabel Is Nothing Then
If myForm.myLabel.Caption = "X" Then
Unload myForm 'DOES NOT SEEM TO BE WORKING...
End If
End If
Next
End Sub