How to Center VBA UserForms on Multi-Monitor Displays
Question details
The user needs to center a VBA UserForm properly on a multi-monitor setup because the default property places it incorrectly.
- Product
- WPS Spreadsheet / Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running a macro-enabled workbook featuring a custom UserForm on a multi-monitor display.
- Observed behavior
- The VBA UserForm appears on the far left of the display instead of being centered, even though the StartUpPosition property is set to CenterScreen.
Ensure you have access to the Developer tab and that your file is saved as a Macro-Enabled Workbook (.xlsm) so you can modify the underlying VBA code.
Set StartUpPosition to Manual and Calculate Coordinates
Override the default CenterScreen behavior by manually calculating the center of the active application window using VBA code.
The StartUpPosition property often miscalculates the center point across extended displays. By forcing it to Manual, you can use mathematical formulas relative to the application window to position the form dynamically.
Press Alt + F11 on your keyboard to launch the Visual Basic for Applications editor.
In the Project Explorer, select your UserForm. Press F4 to open the Properties window, and change the StartUpPosition property to '0 - Manual'.
Right-click the UserForm and select 'View Code'. From the dropdown menus at the top of the code window, choose the 'UserForm_Initialize' or 'UserForm_Activate' event.
Enter the following code to center the form relative to the application: Me.Left = Application.Left + (Application.Width - Me.Width) / 2 and Me.Top = Application.Top + (Application.Height - Me.Height) / 2.
Consult Developer Communities for Advanced API Solutions
If you have a highly complex monitor setup with differing DPIs or scale layouts, you may need specific Windows API calls recommended by specialized developers.
Manage and Run VBA Macros Easily with WPS Office
WPS Office Spreadsheets provides built-in support for VBA macros, allowing you to easily edit UserForms and resolve multi-monitor positioning issues without needing complex third-party tools.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your macro-enabled workbook.
- 2. Access the Developer Tab: Click on the Developer tab in the top ribbon menu and select 'VBA Editor'.
- 3. Modify Your UserForm: Adjust your UserForm properties or add manual positioning code exactly as you would in standard VBA environments.

Frequently Asked Questions
Why does the CenterScreen property fail on multi-monitor setups?
The CenterScreen property often calculates its position based on the primary monitor's resolution or the combined virtual desktop size. This miscalculation can cause the UserForm to appear off-center or snapped to the far left of an extended display.
Can I position a UserForm on a specific monitor?
Yes, but it requires setting the StartUpPosition to Manual and calculating exact X and Y coordinates (Left and Top) via complex Windows APIs or application boundaries relative to that specific monitor.
Is it better to use UserForm_Initialize or UserForm_Activate for positioning?
Using UserForm_Initialize is generally preferred because the coordinates are calculated and set before the form becomes visible. This prevents any screen flickering or visual jumping that might happen if you use UserForm_Activate.




