Is it possible to somehow make it so that when you open a book, two windows with certain sheets open at once? (Is it possible to make the window open to 1/3 of the workspace) mb vba, macros somehow help?

    1 answer 1

    In Excel, you can open two sheets in different windows.

    After opening the book (described for Excel 2010 ):

    Tab on the View-New_window (click), click Restore_window (in the upper right corner, near the Close buttons), then set the required window size, their location, select the desired sheets.

    All this can be done automatically .

    PS Sly "postscript" - passed above the text to which this note, because the solution shown here is better than the macro shown earlier.

    Macro suggested ikki :

    In the EtaBook module insert the code that will work after the book is activated:

    Private Sub Workbook_Open() If Me.Windows.Count = 1 Then Me.Windows(1).NewWindow Else Me.Windows(1).Visible = True Me.Windows(2).Visible = True End If Me.Windows(1).WindowState = xlNormal Me.Windows(Me.Name & ":1").Activate Me.Windows.Arrange ArrangeStyle:=xlVertical End Sub 

    Than the solution is better than the previous one: you do not need to specify the size of the windows, it is enough to specify the location of the windows (in this case, specifying the xlVertical constant)

    If there is a desire to specify the size of windows in the code, then see the code below.

    In the EtaBook module insert the code that will work after the book is activated:

     Private Sub Workbook_Open() Worksheets("Лист1").Activate With ActiveWindow .WindowState = xlNormal .Top = 4 .Left = 4 .Width = 510 .Height = 400 .NewWindow Worksheets("Лист2").Activate ' .Top = 4 .Left = 500 ' .Width = 510 ' .Height = 400 End With End Sub 

    One of the Worksheets sheets ("name_lifes1") is selected, the window sizes ( Width, Height ) and its position ( Top, Left ) are set, the second sheet is activated, the position of this window ( Left ) is selected. Parameters Width, Height, Top for the second window are commented out. If you need to set parameters other than the parameters of the first window, you need to uncomment the lines (remove the apostrophe) and enter the necessary numbers.

    The windows are created, but it is possible that after opening the book, the windows are maximized (apparently only one). For example, this may be the case if there is another code that expands the window to full screen (it may not be registered in this book, but in a personal macro book).

    To display the created windows:

    • put the code in the general module

      Sub two_window ()

       ActiveWindow.WindowState = xlNormal 

      End sub

    • Place a control on the sheet, an object (you can use the Insert-Shapes tab, select an object), right-click on the object, Assign_Macros (select the name of the macro, here two_window ) -OK.

    Everything. After opening the book, you need to press the button - two windows are open, you can work.

    If desired, the button can be placed on the tape.

    Where should be placed macros, you can read in the topic

    How to automatically open a macro in excel when opening a book?