Z Order of UserForms

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
Is there a way of keeping one userform on top of another, without it being modal. I have two userform, userform 1 and 2. If useform2 is modal, I can not click on the listbox and have to close it in order to select an item from userform1 list box. If I close userform2 it also closes userform1

My problem is if both forms are visible and i click on userform 1 then form two goes to the back, I need it to stay on top of form1

Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I am not sure the size of your UserForms, but if you play around with the .Left and .Top options you can get UserForm1 & UserForm2 to be shown
VBA Code:
Sub ShowUserFormTest()
    With UserForm1
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
        .Show
    End With
    With UserForm2
        .StartUpPosition = 0
        .Left = Application.Left + (1.8 * Application.Width) - (1.8 * .Width)
        .Top = Application.Top + (1.8 * Application.Height) - (1.8 * .Height)
        .Show
    End With
End Sub
 
Upvote 0
userform1 can be resizable, mainly it takes up the bulk of the screen or can be change to full screen. Userform 2 is as big as an average message box and opens in the center of the screen.

I don't think your code will keep useform2 on top of userform1, which is what I am after.
 
Upvote 0
Like i said, you have to play around with the numbers to get your UserForm2 above UserForm1.

Change the 1.8 to different numbers and play around with it.
VBA Code:
       .Left = Application.Left + (1.8 * Application.Width) - (1.8 * .Width)
       .Top = Application.Top + (1.8 * Application.Height) - (1.8 * .Height)
 
Upvote 0
I still can not get this to work, I was having a look at this External Site, however it is more to do with a window rather than 2 userforms. Good site for other codes though which you might find usefull.

PS (click on the word "The Code" uder the HEADING "Table of Content" to see the code)
 
Upvote 0
I'm trying to use this Link to keep a Userform2 on top of Userform1, but I keep getting an error message

1595693196291.png


Originally I want Form2 to be onto of Form1, however I could not even get it to work as normal. I am assuming that IF this ever works then I need to change Form1 to Form2 in the above code.

Download Link of Example Here
 
Upvote 0
Tenho um userform principal (userform1) que tem multpage. Em uma das page, tem uma listbox e um botão de comando. Quando o usuário clica em um item da lisbox e aperta no botão de comando, abre um formulário para editar as informações dessa listbox. até aí tudo bem, o problema é que eu não consigo deixar o userform2 aberto a cada click na caixa de listagem do useform1, isso funcionaria se o listbox1 não estivesse em tela cheia, mas está. Alguma ideia ?
 
Upvote 0
@Andre21
Please start a thread of your own for this question.
Also threads in the "Excel Questions" should be posted in English, or if you prefer you can post in your own language here Questions in Other Languages
 
Upvote 0
This is resolved, I have placed the answer here on this post for another users

My Post Mr Excel
 
Last edited:
Upvote 0
@Sharid, please post your solution here in your original question, if possible as a macro instead of giving a sample workbook link only since most Internet users wouldn't prefer to download a file from an unknown source. This way, this thread would help many more future readers.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,497
Members
448,967
Latest member
visheshkotha

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