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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,216,099
Messages
6,128,822
Members
449,470
Latest member
Subhash Chand

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