Create New Excel Window - size and position are TOTALY WRONG!


New Member
Aug 1, 2011
I'm working on a small project in Excel (Office 365) where I'm starting to lose my mind, since code is behaving crazy! :banghead:

The idea is to open two windows of same Excel workbook at the same time, side-by-side, with specific window dimensions. I prepared an example of new workbook "Book1.xlsm" with two Worksheets ("Sheet1" and "Sheet2"). After pressing the "CommandButton1", there should be two windows of the Workbook placed on my monitor side by side with next properties:

  • Left window showing "Sheet1" (Top=0, Left=0, Height=880, Width=960)
  • Right window showing "Sheet2" (Top=0, Left=960, Height=880, Width=960)

I have two-monitor setup with screen resolution 1920×1200 each. You can see that I'm trying to place each window on one half of the monitor (2 × 960 px = 1920 px).

BUT(!) when the code is executed, the size and position of both windows are all WRONG:

  • Left window showing "Sheet1" (Top=-2, Left=-2, Height=1173, Width=1280)
  • Right window showing "Sheet2" (Top=-2, Left=1278, Height=1173, Width=1280)

Does anyone knows why is Excel ignoring size properties set in code and positions windows on these bizarre coordinates? Can someone please check the code and posts the results here? Thank you in advance!

Here is link to file Book1.xlsm in my Dropbox and here is also the code behind "CommandButton1":

Private Sub CommandButton1_Click()

Application.ScreenUpdating = False

'Get rid of all open windows to start at 1. Easier than determining which windows are open and processing them.

Do Until Windows.Count = 1



Application.WindowState = xlMaximized

ActiveWindow.WindowState = xlMaximized

Application.WindowState = xlNormal

'Create 1 more for a total of 2 windows.


ActiveWindow.DisplayGridlines = False

ActiveWorkbook.Windows.Arrange ArrangeStyle:=xlVertical

For Each wnWin In Windows

    Select Case wnWin.WindowNumber

    'Right window: "Sheet2"

        Case Is = 2



            With wnWin

                .WindowState = xlNormal

                .Top = 1

                .Left = 960

                .Height = 880

                .Width = 960

                .DisplayGridlines = False

                .DisplayHeadings = False

             End With

    'Left window: "Sheet2"

        Case Is = 1




            With wnWin

                .WindowState = xlNormal

                .Top = 0

                .Left = 0

                .Height = 880

                .Width = 960

                .DisplayGridlines = False

                .DisplayHeadings = False

            End With

    End Select

Next wnWin

Application.ScreenUpdating = True

End Sub

Disclamer: since I'm quite of noob in VBA, I'm gathering code parts from all over the internet. The code above is modified code, found on Stack Overflow.


New Member
Aug 1, 2011
To make shorter version of my original post: it is maybe easier if I make a poll here:

Please test button in this file and post the result. I hope you can estimate the size of both windows ...


Forum statistics

Latest member
Shahzad Taimoor

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...