Clicking to open/hide a userform

Jaybe08

New Member
Joined
Jul 9, 2010
Messages
8
Background: I'm new to Excel VBA, so please bear with me.

Issue: I have two userforms. One main userform (Userform1) and another userform (Userform2) that the user can choose to open and close.
How can I implement this?
I've searched this forum and attempted to solve it like this (but I doesn't work):
Private Sub cmdShow_Click()
If Userform1.ActiveControl Is Nothing Then
Userform2.Show
Else
Unload Userform2
End If
I appreciate any help.
Thanks!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Welcome to the Board!

Are they going to open UF2 from UF1? If so it'd just be:

Code:
Private Sub cmdShow_Click() 
  Unload Me
  Userform2.Show
End Sub

HTH,
 
Upvote 0
I want the main userform to stay open. But I was able to find this code, which worked.

Function IsUserFormLoaded(UserFormName As String) As Boolean
Dim UF As Object
For Each UF In UserForms
If UCase(UF.Name) = UCase(UserFormName) Then
IsUserFormLoaded = True
Exit Function
End If
Next
End Function

Thanks for your help though.
:)
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top