How to Remove Gridlines in Excel (Shortcut + VBA)

By default, light gray colored gridlines are visible in the worksheet area in the Excel file.

These gridlines are like a border around each cell that shows you the outline of the cell.

In most cases, Excel users are okay with having the gridlines visible in the worksheet. But in many cases, removing these gridlines is required (as it makes your worksheet look cleaner).

In this short tutorial, I will show you how to remove gridlines in Excel quickly. You can do this using the option in the ribbon, or a keyboard shortcut that I’ll cover in this tutorial.

Remove Gridlines in Excel Using the View Tab

Below are the steps to remove the gridlines from the worksheet in Excel:

  1. Click the View tab
  2. In the Show group, uncheck the ‘Gridlines’ option
Uncheck the gridlines option

The above steps would instantly remove the gridlines from the active worksheet.

And if you need to get the gridlines back again, follow the same steps and check the ‘Gridlines’ option in Step 2.

The same steps are also valid if you’re using a Mac.

Note that when you use this method to remove the gridlines, it’s only removed from the active sheet. All the other sheets in your workbook would not be impacted.

Also, this would not impact any new sheet that you insert in the workbook (which would continue to have the gridlines as it’s the default setting).

Shortcut to Remove Gridlines in Excel

Below is the keyboard shortcut you can use in windows to quickly remove the gridlines in Excel:

ALT + W + V + G

Press the keys in succession (one after the other).

Also read: How to Create Barcodes in Excel

Remove Gridlines from All the Worksheets in One Go

As I mentioned earlier, when you remove the gridlines using the keyboard shortcut (or using the option in the View tab), it only removes the gridlines in the active sheet.

But what if you want to remove the gridlines from all the sheets in the workbook?

Here are two ways to do that.

Selecting all Worksheets

When you select more than one worksheet, they get grouped together and any action that you take on the active worksheet would also be done on all the remaining selected sheets.

Below are the steps to remove the gridlines from all the sheets in one go:

  1. Select all the sheets from which you want to remove the gridlines. To do this, hold the Control key and then select all the sheet tabs (or hold the shift key and select the first and the last sheet tab)
Group all the sheets
  1. Click the ‘View’ tab
  2. Uncheck the ‘Gridlines’ option
Uncheck the gridlines option
  1. [VERY IMPORTANT] Right-click on any of the sheet tabs and then click on ‘Ungroup Sheets’
Ungroup the sheets

Note that it is really important that you follow Step 4 – which would ungroup all the sheets that have been grouped in step 1. If you don’t do this, anything that you do on the active sheet would also be done for all the other worksheets (since these are now grouped).

Using VBA

While the previous method works well, it could be quite messy if you have a lot of worksheets from which you want to remove the gridlines.

Also, a lot of people forget to ungroup the worksheets, which can create havoc.

So let me show you a simple VBA code that can quickly cycle through all your worksheets and remove the gridlines in less than a second.

Below is the VBA code that would go through each worksheet and then remove the gridlines.

It would then return back to the original worksheet that was activated while running the code.

'Code developed by Steve Scott from https://spreadsheetplanet.com
Sub Remove_Gridlines()
Dim CurrentSheet As Worksheet
Set CurrentSheet = ActiveSheet
For Each sh In Sheets
sh.Activate
ActiveWindow.DisplayGridlines = True
Next sh
CurrentSheet.Activate
End Sub

Where to Place this VBA code to Remove Gridlines?

Below are the steps to place this VBA code in the VBA editor in Excel so that you can run it:

  1. Click the Developer Tab (if you don’t see the developer tab, click here to see how to get it)
  2. Click on the Visual Basic icon
Click the visual basic icon
  1. [OPTIONAL] If you don’t see the ‘Project Explorer’, click on the View option in the menu and then click on ‘Project Explorer’
  2. Select any object in the workbook in which you want to put this code (you will see these objects in the ‘Project Explorer’ section)
Select any object in the project explorer
  1. Click the ‘Insert’ option in the menu
  2. Click on ‘Module’ – this will insert a new module
Insert a module
  1. Double-click on the Module that is inserted in the Project Explorer
  2. Copy and paste the above code into the Module code window
Copy paste the code in the module code window

To run the VBA code, select any line in the code and then click on the green run icon in the toolbar in the VB editor.

Run the macro by clicking on the green play button

If you need to use this code quite often to remove the gridlines from the entire workbook, it would be better to save this code in the Personal Macro Workbook. Any code that is saved in the Personal Macro Workbook becomes available for all the Excel Workbooks on your system.

Also read: How to Remove Borders in Excel? 6 Easy Ways!

Change the Default Color of the Gridlines (Darken/Lighten the Gridlines)

Many people do not like the light gray color of the gridlines and wonder if the color could be changed to something else (maybe a bit darker).

Thankfully, this can be done.

Below are the steps to change the default color of the gridlines in Excel:

  1. Click the File tab
  2. Click on Options
  3. In the Excel Options dialog box, click on the Advanced category
Select advanced option in the Excel options dialog box
  1. Scroll down to the ‘Display Options for this worksheet’ option
  2. Select the Gridline color you want
Select the gridline color

While this works well, one limitation of this method is that it will only change the gridlines in the active sheet.

If you want to change the gridlines color of all the sheets, you would first have to select all the sheets (which would group them), and then follow the above steps.

Also, remember to ungroup the sheets once you’re done.

This would also not change the gridline color of any new Excel workbook that you create.

Change Gridlines Color Using VBA

Below is the VBA code that would change the gridline color of all the worksheets in your workbook.

Sub Change_Gridlines_Colors()
Dim CurrentSheet As Worksheet
Set CurrentSheet = ActiveSheet
For Each sh In Sheets
sh.Activate
ActiveWindow.GridlineColor = vbBlue
Next sh
CurrentSheet.Activate
End Sub

Note that I have specified the color as vbblue in step 6. You can change this to any color you want. You can either use VBA inbuilt color commands (such as vbRed or vbGreen, or the RGB notation)

Also read: Excel Scroll Bar Too Long (How to Reset it)

Can you Remove Gridlines from Some Parts of the Worksheet, But Keep Them in the Rest?

Unfortunately not.

When you remove gridlines in Excel, it would be removed from the entire worksheet. You cannot selectively keep the gridlines in some parts of the worksheet and remove them from the rest.

However, a workaround is to remove the gridlines from the entire worksheet and then use the borders option to apply borders to the cells where you want to show a grid.

So these are the methods you can use to remove gridlines in Excel. I’ve also covered how to remove gridlines from all the worksheets in one go using the worksheet grouping method or VBA

I hope you found this Excel article useful.

Other Excel tutorials you may also like:

I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.

Leave a Comment