logo
search
VBA & Macro Problems

How to Center VBA UserForms on Multi-Monitor Displays

Maira MehtabMaira Mehtab Sep 20, 2026 869 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to launch the Visual Basic for Applications editor.

2
Change StartUpPosition

In the Project Explorer, select your UserForm. Press F4 to open the Properties window, and change the StartUpPosition property to '0 - Manual'.

3
Access the Initialization Event

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.

4
Insert Positioning Logic

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.

Seamless Centering: This method centers the UserForm directly over the active Spreadsheet window, regardless of which monitor the application is currently occupying.
Powerful VBA Editor

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. 1. Open WPS Spreadsheet: Launch WPS Office and open your macro-enabled workbook.
  2. 2. Access the Developer Tab: Click on the Developer tab in the top ribbon menu and select 'VBA Editor'.
  3. 3. Modify Your UserForm: Adjust your UserForm properties or add manual positioning code exactly as you would in standard VBA environments.
Fully compatible with Microsoft Excel VBA scripts and macro-enabled formats (.xlsm, .xls)Built-in Visual Basic Editor for modifying UserForm properties and writing custom logicLightweight performance for executing advanced data processing scripts seamlessly
microsoft office alternative - wps office

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.