Split windows : Excel « Excel « VBA / Excel / Access / Word






Split windows

 
Sub SplitWindow()
  Dim freezeMode As Boolean, win As Window
  If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
 
  Set win = ActiveWindow
  freezeMode = win.FreezePanes
  win.FreezePanes = False
  
  If win.Split Then win.Split = False: Exit Sub
  win.SplitRow = ActiveCell.Row - win.ScrollRow
  win.SplitColumn = ActiveCell.Column - win.ScrollColumn
  win.FreezePanes = freezeMode
End Sub

 








Related examples in the same category

1.Get the Excel version
2.Turn row/column headers and gridlines on/off