No gridlines

mickeystanford_alumni

Board Regular
Joined
May 11, 2022
Messages
129
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
Hi guys,
Is there any way to get rid of the gridlines forever? Maybe a code to do so?
I have an big excel where I have to manually click on: View/Gridlines, however, when I save the file, the next day I open it it is again with the gridlines.

Any help?

Thxs a lot
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Since you are saving the workbook, by default, it should maintain the condition. Anyway you could add this code to the ThisWorkBook module:
VBA Code:
Option Explicit
Private Sub Workbook_Open()
    ActiveWindow.DisplayGridlines = False
End Sub
This gets rid of the gridlines in the active sheet. If it has to be done on all sheets you can add a loop to do so.
 
Upvote 0
Paste this code into Workbook:
VBA Code:
Private Sub Workbook_Open()
  Dim ws As Worksheet
  Set ws = ActiveSheet
  Application.ScreenUpdating = False
  ReDim gridLines(Worksheets.Count - 1)
  For i = 0 To Worksheets.Count - 1
    Worksheets(i + 1).Activate
    ActiveWindow.DisplayGridlines = False
  Next
  ws.Activate
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Paste this code into Workbook:
VBA Code:
Private Sub Workbook_Open()
  Dim ws As Worksheet
  Set ws = ActiveSheet
  Application.ScreenUpdating = False
  ReDim gridLines(Worksheets.Count - 1)
  For i = 0 To Worksheets.Count - 1
    Worksheets(i + 1).Activate
    ActiveWindow.DisplayGridlines = False
  Next
  ws.Activate
  Application.ScreenUpdating = True
End Sub
Thank you so much!
 
Upvote 0
Thanks for the feedback (y) You may delete the line below. I put it there for testing reasons:
VBA Code:
ReDim gridLines(Worksheets.Count - 1)
 
Upvote 0

Forum statistics

Threads
1,215,328
Messages
6,124,295
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top