How do you move UserForm to Right hand side of screen with VBA?

D

Dennis

The Userform usually come up in the center of the screen.

Given that different users have different resolutions on their screens how do
you move the Userform to the right hand side of the screen with it being
centered vertically no matter what the user screen resolution is?

Thanks

Dennis
 
R

Ron de Bruin

Hi Dennis

Try this in the userform module

Private Sub UserForm_Initialize()
Me.StartUpPosition = 0
Me.Top = (Application.Height / 2) - Me.Height / 2
Me.Left = Application.Width - Me.Width + Application.Left
End Sub
 
D

Dennis

Thanks Ron that worked.

I had to change the Me.Left to clear the scroll bar on the right to:

Me.Left = Application.Width - Me.Width + Application.Left - 20

Thanks again.

Dennis
 
Top