Hi All,
I have a workbook with multiple worksheets, with one worksheet that has two macros assigned to buttons on that one sheet. The macros are designed to vertically split the window, then to reset the view to normal.
The macro attached to the first button is:
Sub SplitView()
' vertically splits view
ActiveWindow.NewWindow
Windows.Arrange ArrangeStyle:=xlVertical
End Sub
The macro attached to the second button is:
Sub ResetView()
' Resets view after split
ActiveWindow.Close
ActiveWindow.WindowState = xlMaximized
ActiveWindow.Zoom = 95
End Sub
Both macros work fine as long as that one sheet is active. The problem is, when I switch to a different sheet in that workbook, or a different sheet in a different workbook, without resetting the view first, the split view remains and I get multiple vertical windows.
When I tried this code in the worksheet object:
Private Sub Worksheet_Deactivate()
Application.EnableEvents = False
ActiveWindow.Close
ActiveWindow.WindowState = xlMaximized
Application.EnableEvents = True
End Sub
The view will reset but I keep getting a prompt to save changes to the workbook when I switch to a different sheet.
Any guidance as to what I am doing wrong would be greatly appreciated, thanks!
Bookmarks