userform to appear in the center of the screen

E

ernie

how can i get my userform to appear in the center of the screen even if i
change my screen resolution settings. i use the code below with screen
resolution of 1024 by 768 pixels.

Private Sub Workbook_Open()
Application.WindowState = xlNormal
Application.Top = 250
Application.Left = 320
Application.Height = 1
Application.Width = 1
End Sub
 
J

JLGWhiz

See StartUpPosition in the VBA Help. CenterOwner is the position preset for
the UserForm.
 
J

JMay

The following code needs to be pasted into the Code
Behind your Userform:

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

Write back if you encounter problems;

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top