Private Function FormIsLoaded(UFName As String) As Boolean
Dim UF As Integer
For UF = 0 To VBA.UserForms.Count - 1
FormIsLoaded = UserForms(UF).Name = UFName
If FormIsLoaded Then Exit Function
Next UF
End Function
Sub Test()
'Load UserForm1
MsgBox FormIsLoaded("UserForm1"), 64
'If FormIsLoaded("UserForm1") Then Unload UserForm1
End Sub
Private Sub CommandButton1_Click()
If (UserForm1 Is Nothing) Then
MsgBox "UserForm1 is inactive"
ElseIf Not UserForm1.Visible Then
MsgBox "UserForm1 is inactive"
Else
MsgBox "UserForm1 is active"
End If
End Sub
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.