How to Check If an Excel VBA UserForm Is Maximized
Question details
The user wants to find out how to programmatically check whether an Excel VBA UserForm is currently maximized.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Developing or debugging a VBA macro that relies on knowing the current window state of a UserForm to trigger specific dynamic resizing or layout adjustments.
- Observed behavior
- Excel VBA does not provide a built-in 'IsMaximized' property for UserForms, making it impossible to check the state directly without a workaround.
Ensure you have access to the Developer tab and the VBA Editor (ALT + F11), and that your UserForm contains valid dimensions before attempting to calculate its state.
Use a VBA Helper Function to Compare Dimensions
Because UserForms lack a native maximize property, you can write a VBA function to check if the form's dimensions match or exceed the usable Excel application area.
This method serves as a practical approximation. It captures the width and height of the current usable application workspace and compares it against the dimensions of the active UserForm.
Keep in mind that UserForms do not natively support standard Windows maximize behaviors by default. This method is highly effective for simulated maximize setups.
Press ALT + F11 to open the Visual Basic for Applications (VBA) editor. Insert a new Module by clicking 'Insert' > 'Module' in the top menu.
Copy and paste the following code into the module: Function IsUserFormMaximized(userForm As Object) As Boolean Dim availableWidth As Long Dim availableHeight As Long availableWidth = Application.UsableWidth availableHeight = Application.UsableHeight IsUserFormMaximized = (userForm.Width >= availableWidth And userForm.Height >= availableHeight) End Function
Whenever you need to verify the state, call the function and pass your UserForm instance to it. For example, use 'If IsUserFormMaximized(UserForm1) Then' to execute code conditionally based on the maximized state.

Track the Maximize State via Custom Variables
If you are using Windows API calls to add a native maximize button to your UserForm, tracking the state manually via a custom variable is a more reliable approach.
Run VBA Macros and UserForms Seamlessly in WPS Office
WPS Spreadsheet offers comprehensive support for Excel VBA macros and UserForms. You can easily create, edit, and run your VBA code using the built-in Developer tools without having to modify your existing scripts.
- 1. Download and Install: Download WPS Office for free and install it on your computer.
- 2. Enable the Developer Tab: Open WPS Spreadsheet, go to the settings menu, and ensure the Developer tab is enabled to access macro tools.
- 3. Open the VBA Editor: Click 'VBA Editor' on the Developer tab or press ALT + F11 to manage your UserForms exactly as you would in Microsoft Excel.

Frequently Asked Questions
Why doesn't Excel VBA have an IsMaximized property for UserForms?
VBA UserForms were originally designed as fixed-size dialog boxes rather than fully resizable application windows. Because standard Windows minimize and maximize buttons are not natively included on UserForms, a corresponding property was never built into the standard VBA library.
Does Application.UsableWidth account for the Windows taskbar?
No, Application.UsableWidth and Application.UsableHeight refer strictly to the maximum space available within the Excel application window's workspace. It does not measure the overall monitor resolution or account for the Windows taskbar.
Can I add native Minimize and Maximize buttons to my VBA UserForm?
Yes, but doing so requires writing advanced code using Windows API calls (such as FindWindow and SetWindowLong) to modify the UserForm's window style at runtime, as these buttons are not available in the standard VBA Properties window.




