Turn row/column headers and gridlines on/off : Excel « Excel « VBA / Excel / Access / Word






Turn row/column headers and gridlines on/off

 
Sub ToggleHeadingsGrids()
  Dim gridMode&, headingsMode&
 
  On Error Resume Next
 
  headingsMode = ActiveWindow.DisplayHeadings
  gridMode = ActiveWindow.DisplayGridlines
 
  If headingsMode And Not gridMode Then
    headingsMode = False
  ElseIf Not headingsMode And Not gridMode Then
    gridMode = True
  ElseIf Not headingsMode And gridMode Then
    headingsMode = True
  Else
    gridMode = False
  End If
 
  ActiveWindow.DisplayHeadings = headingsMode
  ActiveWindow.DisplayGridlines = gridMode
End Sub

 








Related examples in the same category

1.Get the Excel version
2.Split windows