How To Hide Or Show Gridlines In Excel Worksheet

This article will tell you how to hide or show gridlines in an Excel worksheet both manually and using VBA. It will also tell you how to show or hide the gridlines when printing the Excel worksheet.

1. How To Hide Or Show Gridlines In Excel Worksheet.

1.1 How To Hide Or Show Gridlines In Excel Manually.

  1. Open an Excel worksheet.
  2. Click the View tab on the Excel top area.
  3. Uncheck the checkbox Gridlines in the Show group to hide gridlines in the worksheet.
  4. Check the checkbox Gridlines in the Show group to show gridlines in the worksheet.

1.2 How To Hide Or Show Gridlines In Excel Using VBA.

  1. Click the Developer tab on the Excel top area.
  2. Then click the Visual Basic icon to open the Microsoft Visual Basic window.
  3. Click the Insert —> Module menu item to insert a VBA module.
  4. The Excel ActiveWindow.DisplayGridlines property can be used to hide or show gridlines in the Excel worksheet.
  5. If the ActiveWindow.DisplayGridlines value is True, then it will show the gridlines in the Excel worksheet.
  6. If the ActiveWindow.DisplayGridlines value is False, then it will hide the gridlines in the Excel worksheet.
  7. Copy the below VBA source code in the VBA Module window.
    ' Define a module to hide or show gridlines in the excel worksheet.
    Sub Hide_Show_Gridlines()
    
    ' If the gridlines are shown in the active worksheet.
    If ActiveWindow.DisplayGridlines Then
      
         ' Hide the gridlines by setting the DisplayGridlines property to False.
         ActiveWindow.DisplayGridlines = False
    
    Else
    
        ' If the gridlines are hidden, then show it by setting the below property to True.
         ActiveWindow.DisplayGridlines = True
    
    End If
    
    End Sub
  8. Select the above module source code, then click the run button to execute it, and it will hide the gridlines from the Excel worksheet.
  9. When you execute the above source code again, it will show the gridlines in the Excel worksheet.

2. How To Show Or Hide Gridlines When Printing Excel Worksheet.

  1. Click the Page Layout tab on the Excel top area.
  2. Check the checkbox Print in the Gridlines section, then it will print out the gridlines when you print the worksheet.
  3. If you uncheck the checkbox Print in the Gridlines section, then it will not print out the gridlines when you print the worksheet.
  4. If you check the View checkbox under the Gridlines section, then it will show the gridlines in the worksheet.
  5. If you uncheck the View checkbox under the Gridlines section, then it will hide the gridlines in the worksheet.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.