Inside The Web
    Facebook Twitter Instagram
    Inside The Web
    • Office
      • Excel
      • Ms Word
      • OneDrive
      • Google Docs
      • Google Sheets
      • Google Drive
    • Email
      • Gmail
      • Outlook
      • Emal Etiquette
    • Office Etiquette
    • Productivity
    Inside The Web
    Home»Office»Excel»How to Change the Window Size in a Macro in Excel?

    How to Change the Window Size in a Macro in Excel?

    Nisha GurungBy Nisha GurungNovember 17, 2023 Excel 2 Mins Read

    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

    1. Launch Excel Workbook.
    2. To open the VBA Editor Window, press Alt + F11 keyboard shortcut.
    3. Click Insert and pick Module.
      Click Insert and pick Module
    4. Copy and Paste this code into your VBA.
      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
    1. 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.

    1. On your Sheet, enter Alt + F11. 
    2. Go to Insert and select Module.
      Go to Insert and pick Module
    3. Copy and Paste the code into VBA. Make sure to enter the pixel number in “Width” and “Height”
      VBA window to set program Excel window size
    Sub SetCustomWindowSize()
    Application.Width = “width pixels”
    Application.Height = “height pixels”
    End Sub
    1. Press F5. 
    Advanced Excel
    Nisha Gurung

      As a Business Student, Nisha first used Excel to outline data trends for her college projects. Later, she started exploring basic Excel functions when she realized it is a powerful tool for all businesses today. Nisha believes she can relate to many of the issues users face when starting their Excel Journey. She uses this knowledge and experience to curate contents that are fit for all types of Excel users. Apart from writing, she enjoys reading books and traveling.

      Related Posts

      Excel By Nisha Gurung

      How to Compare Two Columns in Excel Using VLOOKUP

      Excel By Nisha Gurung

      How to Share Excel Files with Multiple Users

      Excel By Nisha Gurung

      How to Filter Based on a List in Excel

      Add A Comment
      Table of ContentsToggle Table of ContentToggle
      • Maximize Window Size
      • Custom Window Size
      • Home
      • About Us
      • Privacy Policy
      © 2025 Inside The Web

      Type above and press Enter to search. Press Esc to cancel.