Hello
I've button which loads Userform2.
In Second command button i want to know whether userform2 is loaded
in Gen Module
in Userform1
Thanks NimishK
I've button which loads Userform2.
In Second command button i want to know whether userform2 is loaded
in Gen Module
Code:
Public usrForm As Object
Function IsUserFormLoaded(ByVal usfrName As String) As Boolean
IsUserFormLoaded = False
For Each usrForm In VBA.UserForms
If usrForm.Name = usfrName Then
IsUserFormLoaded = True
Exit For
End If
Next
End Function
in Userform1
Code:
Private Sub cmd1_Click()
Load UserForm2
UserForm2.Show vbModeless
End Sub
Private Sub cmd2_Click()
''''Option 1
If IsUserFormLoaded("Userform2") Then
MsgBox "Form Loaded:"
End If
[B]Here No Msgbox with msg is displayed even if form is loaded[/B]
''''Option 2
If usrForm.Name = "Userform2" Then
[COLOR=#ff0000][B]'Error on the above line " Object Variable or With Block Variable not set
[/B][/COLOR] MsgBox "Form Loaded:"
End If
End Sub
Last edited: