Centre Userform For Dual Or Multiple Displays

less than 1 minute read

Force the userform to load to the centre of the active excel window, add this code to the userform Initialize event. Perfect for when you have more than 1 active monitor

'==================================================================================================
' ## Force the userform to load to the centre of the active excel window
'    add this code to the userform Initialize event
'==================================================================================================
Private Sub UserForm_Initialize()
    With Me
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
    End With
End Sub

Tags:

Categories:

Updated: