Userform show / hide

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
303
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a userform, call it UserForm1. It contains five buttons. If the user clicks button1 I have some simple code that does
VBA Code:
Private Sub CommandButton1_Click()
UserForm2.Show
End Sub

UserForm2 appears with whatever data I have populated it with. That userform has a QUIT button which has some code that does
VBA Code:
Private Sub CommandButton1_Click()
Unload Me
End Sub

UserForm1 is then visible again.

I've had a couple of instances (sporadic) where UserForm1 has remained visible on top of UserForm2. Clicking on UserForm2 makes UserForm1 disappear. I don't know if Excel is just having a moment but this file is aimed at very non-techy people and two forms visible is going to confuse them.

Is there a way of forcing UserForm1 to disappear and then reappear once UserForm2 is closed so that I can be sure only one form is visible at any one time?

This is in a corporate environment so calls to the API aren't an option.

Thanks for reading!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You could try this in UF1's code that calls UF2.
VBA Code:
Private Sub CommandButton1_Click()
    Me.Hide
    UserForm2.Show
    Me.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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