Excel multiple userforms

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi All

I have two userforms, Userform1 and UserForm2, and I have commandButton1 and commandbutton 2 to open up these two userforms in the worksheet.

VBA Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Private Sub CommandButton1_Click()
 
'UserForm1.Show vbModeless

UserForm1.Show
 
End Sub
 
Private Sub CommandButton2_Click()


UserForm2.Show

 
End Sub[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/CO[/COLOR][/SIZE][/FONT]DE]

However, only the commandbutton1 works to open the userform1 but when I click the commandbutton2 the userform2 doesn't show and there is no error message.  Please could anyone help me to resolve this?  Thanks.
 

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.
To open up Two Userforms you need to open them like this:
Now you must realize if they are both the same exact size they may be setting on top of each other.
VBA Code:
Sub Show_Me()
'Modified  2/24/2020  12:03:17 PM  EST
UserForm1.Show Modeless
UserForm2.Show Modeless
End Sub
 
Upvote 0
Thanks. How about if I want user to open them separately, to close down another one before open up another one? Thanks.
 
Upvote 0
Not sure what you want exactly.
You want user to click one button to close one Userform1 and at the same time Open Userform2?

It would be something like this.

Unload Userform1
Userform1.show
 
Upvote 0
To open up Two Userforms you need to open them like this:
Now you must realize if they are both the same exact size they may be setting on top of each other.
VBA Code:
Sub Show_Me()
'Modified  2/24/2020  12:03:17 PM  EST
UserForm1.Show Modeless
UserForm2.Show Modeless
End Sub
What is modeless used for?
 
Upvote 0
Thank you! it works perfectly!
Please could you tell me where to see the properties of the cammandbutton so as to rename it? When I view the code, I can only see the properties of worksheet1 but commandbuttons are not there. Many thanks.
 
Upvote 0
Thank you! it works perfectly!
Please could you tell me where to see the properties of the cammandbutton so as to rename it? When I view the code, I can only see the properties of worksheet1 but commandbuttons are not there. Many thanks.
You need to click on the command button. Then look in properties window and you will see where to replace name. It's the first one in the properties window.

On another subject.
Why do you need two Userforms?
Have you ever looked at using a Userform Multipage control?
Look in the Userform Tool Box put one on your empty Userform and see how it works.
It's like have several Userforms all on the same Master Userform.
 
Upvote 0
Thank you! I do need two userforms and they both already have multiple pages on. They are for different purposes. Many thanks for your help. I appreciate it very much!
 
Upvote 0
Thank you! I do need two userforms and they both already have multiple pages on. They are for different purposes. Many thanks for your help. I appreciate it very much!
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
 
Upvote 0

Forum statistics

Threads
1,223,921
Messages
6,175,379
Members
452,639
Latest member
RMH2024

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