Sub SplitWindow()
Dim freezeMode, win As Window
If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
Set win = ActiveWindow
freezeMode = win.FreezePanes
win.FreezePanes = False 'else the split cannot be changed
If win.Split Then win.Split = False: Exit Sub 'cancel split
win.SplitRow = ActiveCell.Row - win.ScrollRow
win.SplitColumn = ActiveCell.Column - win.ScrollColumn
win.FreezePanes = freezeMode 'restore split
End Sub
|