Dock multiple UserForms?

buvb10

New Member
Joined
May 31, 2005
Messages
21
Hey all,

Here's my first post - just learned of mrexcel.com!

I have two UserForms with initialization events as follows:

UserForm1
Me.StartUpPosition = 0
Me.Top = 0
Me.Left = Application.Left + Application.Width - Me.Width

UserForm2
Me.StartUpPosition = 0
Me.Top = UserForm1.Height
Me.Left = Application.Left + Application.Width - Me.Width

From this, is there some way to "dock" or link the two forms such that if UserForm1 moves, UserForm2 will move with it?

Thanks everyone!

- Brian
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi, Brian,

try this

Code:
Private Sub UserForm_Layout()
UserForm2.Left = Me.Left
UserForm2.Top = Me.Top
End Sub

or moving just to the left
Code:
UserForm2.Left = Me.Left + Me.Width
kind regards,
Erik
 
Upvote 0
Erik,

Thanks very much for your insight on this.

I made one modification to the Layout code below. This allows the two forms to stack one above the other and then move accordingly.

Private Sub UserForm_Initialize()
'Form startup position top right
Me.StartUpPosition = 0
Me.Top = 0
Me.Left = Application.Left + Application.Width - Me.Width - 5
End Sub

Private Sub UserForm_Layout()
UserForm2.Left = Me.Left
UserForm2.Top = Me.Top + Me.Height
End Sub


thanks!

- Brian
 
Upvote 0
Brian,

you learned me something too: Application.Left ...

do you need this line ?
Me.Top = 0

for me it doesn't make a difference

kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,223,677
Messages
6,173,794
Members
452,534
Latest member
autodiscreet

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