get application in first or second monitor vba code example

Example: userform startup position multiple monitors

Private Sub UserForm_Initialize()
  'PURPOSE: Position userform to center of Excel Window (important for dual monitor compatibility)
  'Start Userform Centered inside Excel Screen (for dual monitors)
  Me.StartUpPosition = 0
  Me.Left = Application.Left + (0.5 * Application.Width) - (0.5 * Me.Width)
  Me.Top = Application.Top + (0.5 * Application.Height) - (0.5 * Me.Height)
End Sub

Tags:

Misc Example