While using Excel, it’s a pretty common practice to resize the Window view as per our needs. Sometimes, we may keep it minimized, maximized, split-view, or in a custom size.
But, what if you want to keep Excel in a certain window size?
Well, the good news is this is also possible with Excel’s Macro. To set the program window size, I have generated VBA codes. Simply run those codes on your VBA Editor tool. The best part is that you can also define your own custom height and width size in that code.
Before you start, you need to have a Developer Tab in your Excel Sheet. So, load them first in your Excel Ribbon.
Maximize Window Size
- Launch Excel Workbook.
- To open the VBA Editor Window, press Alt + F11 keyboard shortcut.
- Click Insert and pick Module.
- Copy and Paste this code into your VBA.
Private Sub Maximize_All_Open_Workbooks()
Application.WindowState = xlMaximized 'maximize Excel
ActiveWindow.WindowState = xlMaximized 'maximize the workbook in Excel
Application.ScreenUpdating = True
End Sub
- Press F5.
Custom Window Size
Here, as an example, I’ve specified the Excel Window Size to appear in 900 width and 500 height pixels. Remember to set your preferred width and height pixels.
- On your Sheet, enter Alt + F11.
- Go to Insert and select Module.
- Copy and Paste the code into VBA. Make sure to enter the pixel number in “Width” and “Height”
Sub SetCustomWindowSize()
Application.Width = “width pixels”
Application.Height = “height pixels”
End Sub
- Press F5.