To open a workbook in a new window with Excel VBA, set the workbook's Windows collection item to NewWindow and then activate it: ThisWorkbook.Windows(1).NewWindow followed by ActiveWindow.Activate. The workbook itself is not duplicated or copied; Excel simply creates another view of the same file, so edits in one window appear in the other. To open a different file in a separate Excel instance, use CreateObject("Excel.Application") instead, then call .Visible = True on that object. Before you start, you need the Developer tab enabled and a macro-enabled workbook (.xlsm), because standard .xlsx files cannot store VBA code.

What You'll Need

  • Microsoft Excel on Windows or Mac (Office 365, Excel 2016 or newer). The VBA editor works on both, though window behaviour differs slightly on Mac.
  • The Developer tab visible. Enable it through File > Options > Customize Ribbon and tick Developer in the right-hand list. On Mac, use Excel > Preferences > Ribbon & Toolbar.
  • Your file saved as .xlsm (Excel Macro-Enabled Workbook). Menu labels can differ slightly by version, device and region.
  • Macro security set to allow macros. If macros are blocked, the code will run but Excel may warn you first, or refuse to run at all.

Step-by-Step

  1. Save your file as macro-enabled. Press F12 (Save As), choose Excel Macro-Enabled Workbook from the file type list, and give it a name. If you leave it as .xlsx, any code you write is lost when you close the file.
  2. Open the VBA editor. Press Alt + F11 on Windows. On Mac, press Option + F11 or use Tools > Macro > Visual Basic Editor. A separate grey window opens.
  3. Insert a module. In the VBA editor, go to Insert > Module. A blank code pane appears in the right-hand area. This is where your code lives.
  4. Paste the basic macro. Type or paste the following into the module:
    Sub OpenNewWindow()
        ThisWorkbook.Windows(1).NewWindow
        ActiveWindow.Activate
    End Sub
    Windows(1) refers to the first window of that workbook. NewWindow creates a second view, and Activate brings it to the front so the reader notices it.
  5. Run it. Press F5 with the cursor inside the routine, or close the editor and use Developer > Macros, select OpenNewWindow, and click Run. You should see a second Excel window showing the same sheet.
  6. Arrange the windows for comparison. Two views of one workbook let you scroll to different sheets independently. To line them up, go to View > Arrange All and pick Tiled or Vertical. Both windows then show side by side.
  7. Name the new window (optional but useful). If you are generating several views and later need to close the right one, capture the object instead of relying on ActiveWindow:
    Sub NamedNewWindow()
        Dim w As Window
        Set w = ThisWorkbook.Windows(1).NewWindow
        w.Caption = "Report View"
        w.Activate
    End Sub
    Setting the caption makes it obvious in the taskbar which view is which.
  8. Open a different file in a truly separate Excel process. A new window is still the same Excel instance. If you need two genuinely independent Excel applications, for example to run two macros at once, use:
    Sub OpenInNewInstance()
        Dim xl As Object
        Set xl = CreateObject("Excel.Application")
        xl.Visible = True
        xl.Workbooks.Open "C:\Path\To\YourFile.xlsx"
    End Sub
    Replace the path with a real one. Setting Visible = True is essential; without it the second Excel runs invisibly in the background.
  9. Close the extra window when done. Use ThisWorkbook.Windows(2).Close if it is the second window, or loop through ThisWorkbook.Windows and close windows beyond the first. Closing an extra window does not close the file, so no data is lost.

Common Mistakes

  • Running Workbooks.Add by mistake. That creates a blank new workbook, not a new window on the current one. The two features are entirely different.
  • Forgetting Visible = True. A CreateObject Excel instance is invisible by default. The code appears to do nothing because the window exists but you cannot see it.
  • Using ActiveWorkbook when focus has moved. If another workbook is active, ActiveWorkbook.Windows(1) refers to the wrong file. Use ThisWorkbook to target the file containing the macro.
  • Saving as .xlsx. Excel strips the VBA project without asking loudly enough. Always check the file type after saving.
  • Expecting the new window to be a copy. It is a view of the same data. Changing a cell in one window changes it in the other instantly.
  • Hard-coded window indexes. If a window is already open, Windows(2) may not be the one you expect. Check ThisWorkbook.Windows.Count first.

Tips

  • Use a new window to show a chart sheet beside its source data, or a pivot table beside its fields list.
  • Freeze panes in one window and leave the other unfrozen, so one stays on headers while the other scrolls freely. The freeze setting is per window, not per workbook.
  • Zoom is also per window, which makes a new window handy for a close-up view of a dense table.
  • Bind the macro to a button: Developer > Insert > Button (Form Control), then assign the macro. A one-click new view is easier for colleagues than the Macro dialog.
  • If you share the file, note that extra windows do not travel with it. Each user starts with one window.
  • For a permanent split view, View > New Window on the ribbon does the same thing without any code, and can be saved in the workbook layout.

Troubleshooting

The macro does nothing. Check that macros are enabled in the Trust Center and that you are editing and running the macro in the same file. If the code ran but no window appeared, look at the taskbar; it may be behind other windows.

"Subscript out of range" error. This usually means the window index does not exist, for example calling Windows(2) when only one window is open. Use Windows(1).NewWindow instead of guessing indexes.

"Object variable or With block variable not set." You referenced an object before assigning it. Add Set before ThisWorkbook.Windows(1).NewWindow when assigning to a variable.

Compile error: Expected: end of statement. Usually a missing parenthesis or a smart quote pasted from a website. Retype the line in the editor so quotes are straight.

The second Excel instance will not close. An invisible instance with no error handling can linger. Close it explicitly with xl.Quit and Set xl = Nothing at the end of your routine.

Nothing works at all. Save, close Excel entirely, reopen, and confirm the Developer tab is visible. If the file arrived by email, it may be blocked by Windows; open the file's Properties and check for an unblock option. As a last resort, copy the code into a brand-new macro-enabled workbook to rule out corruption.

Frequently Asked Questions

What is the difference between a new window and a new workbook?

A new window is another view of the same data, so edits appear in both instantly. A new workbook is a separate, empty file with its own data.

Does opening a new window use more memory?

Only a modest amount. The data is shared between windows, not duplicated, so a second view is far lighter than opening the file twice.

Can I open a specific sheet in the new window?

Yes. After creating the window, activate the sheet in that window with ActiveWindow.Activate and then Worksheets("Sheet2").Activate, or set ActiveWindow.DisplayGridlines and similar properties per window.

Will the new window appear when someone else opens the file?

No. Window count is per session. The saved layout may restore windows for the user who saved it, but other users start fresh.

Does this work in Excel for Mac?

Yes, NewWindow is supported in VBA on Mac Excel, though the VBA editor is opened with Option + F11 and window arranging options are fewer. Behaviour can vary by version, so test it on your own machine.

Can I open a workbook in a new window from another file's macro?

Yes, but target the other workbook explicitly, for example Workbooks("Book1.xlsx").Windows(1).NewWindow, since the new window belongs to whichever workbook you call it on.