How to Remove Gridlines Using VBA

To disable gridlines in Excel automatically using Visual Basic for Applications (VBA), you can follow these steps:

Step 1: Enable the Developer Tab

Go to the “File” menu and choose “Excel Options.”

Select “Customize Ribbons.”

Check the “Developer” box.

Click “OK” to add the Developer tab to your Excel ribbon.

Turn on the Developer Tab

Step 2: Insert a VBA Module

Click the “Developer” tab.

On the far left side, click “Visual Basic.”

In the Project Explorer, right-click the “VBAProject” with your workbook’s filename.

Choose “Insert” from the dropdown menu and then select “Module.”

Insert a VBA Module

Step 3: Insert or Paste Your VBA Code

Type or paste your VBA code into the module. You can copy code from external sources as Excel allows pasting code from the internet.

Add a Command Button

Step 4: Return to the Excel document

Click the “Developer” tab again.

Select “Insert,” and under ActiveX Controls, choose “Command Button.”

Double-click the command button to create it.

In the dialog box that appears, type or paste your VBA code, then close it.

Step 5: Run the Macro

Click the “Macros” button in the Developer tab.

Select your macro (in this case, the one that hides gridlines).

Click “Run” to execute the code. This code will hide the gridlines throughout the workbook.

RUN the Macro

Step 6: Preview the Result

Gridlines removed

How to Remove Grid lines in Excel

When you open the Excel sheet, you see a cross-section of rows and columns with grey-coloured lines that separate cells. Those gray-colored lines are known as gridlines in MS Excel. The grey color is the default color offered by Microsoft and one can change the color of the gridlines. These Guidelines can be helpful in reading data, but they might become distracting or undesirable when presenting or printing the final document.

Borders and Gridlines are two things that create confusion among users, Borders are customizable and one can change their color, type, and width but the same is not true for gridlines.  

Note: Gridlines are always applied on the whole worksheet or workbook, you can’t apply it on one cell or a set of cells. In this case, borders are applicable. 

Similar Reads

What are Gridlines in Excel

In Excel, gridlines are the lines that separate the cells. They help you see where one cell starts and another one ends. Gridlines are like guides that make it easier to work with your data....

How to Remove Gridlines in Excel

Removing gridlines will make your Excel worksheet look like a blank document as shown below:...

How to Remove Grid Lines in Excel Using View and Page Layout Option

Step 1: Go to the Page Layout tab in the ribbon...

How to Show Gridlines in Excel in a Specific Area in the Worksheet

Gridlines can be easily shown if removed from the Excel worksheet. You can either have the gridline visible in the worksheet or hide it completely. There is no way to show this is in a specific area....

How to Change the Color of the Gridlines in Excel

You can also change the color of the Gridlines in Excel, you have the feature to customize it to your preference. Follow the below steps to change the color of the Gridlines:...

How to Remove Gridlines for Specific Cells in Excel

To get rid of gridlines for specific cells in Excel, you can make them look like they don’t have any lines by doing this:...

How to Remove Gridlines Using VBA

To disable gridlines in Excel automatically using Visual Basic for Applications (VBA), you can follow these steps:...

How to Print the Gridlines in Excel

By default, the gridlines in Excel are not printed when you print a worksheet. But if you want the gridlines to be printed, follow the below steps :...

FAQs on How to Remove Gridlines in Excel

How do I get rid of the Grid in Excel?...

Contact Us