How to Hide Gridlines in Excel VBA

By Shawn McClain

The Excel gridlines run between the columns and row of the spreadsheet, allowing you to see where each individual cell is located. While there is a setting in the "View" ribbon that lets you switch the gridlines off, you can also use Excel's built-in programming language, Visual Basic for Applications (VBA), to turn them off. Using VBA code to complete the process allows you to switch off the gridlines automatically as the program processes your code.

Step 1

Open the Excel file that holds your spreadsheet and VBA information. Once the file opens up, press "Alt" and "F11" to launch the VBA console.

Step 2

Select the module that holds your VBA code from the list of sheets and modules on the left side of the VBA console.

Place your cursor into your VBA code on the right half of the console, where you want to enter the code to remove your gridlines. Type the following code into the Excel console: "ActiveWindow.DisplayGridlines = False". Click the "X" in the upper-right corner of the VBA console to close it. When you choose to run the macro from the "Developer" tab, the gridlines will disappear.

×