middle userform excel vba code code example
Example: excel vba center userform
' On application window
Private Sub UserForm_Initialize()
Me.Top = Application.Top + (Application.UsableHeight / 2) - (Me.Height / 2)
Me.Left = Application.Left + (Application.UsableWidth / 2) - (Me.Width / 2)
End Sub
' Or
With myForm
.StartUpPosition = 0 ' Manual
.StartUpPosition = 1 ' CenterOwner
.StartUpPosition = 2 ' CenterScreen
.StartUpPosition = 3 ' WindowsDefault, screen top left
End With