Excel Guides

Setting Program Window Size in a Macro in Excel

To set the program window size in a macro in Excel, you'll need to use the Application.Width and Application.Height properties.

You can set these properties to any value you want, but keep in mind that the values are measured in points. There are 72 points in an inch, so if you want to set the width of the window to 6 inches, you would use a value of 432 (6 x 72).

Here's a simple macro that will set the width and height of the program window:

Sub SetWindowSize()

    Application.Width = 432
    Application.Height = 324
    
End Sub

If you want to make sure that your macro works on different computers, you can use the Application.ScreenWidth and Application.ScreenHeight properties to set the width and height relative to the screen size.

For example, if you want the width of the program window to be half of the screen width, you would use this code:

Sub SetWindowSize()

    Application.Width = Application.ScreenWidth / 2
    Application.Height = Application.ScreenHeight / 2
    
End Sub 	 	 	 	 	 	 	 	 	 	 	 	   

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.