DisplayGridlines = True

I want to enable the gridlines w/o enabling the sheet.  Do I have to activate the sheet before I update the gridline property ?

'this works.
    ActiveWindow.DisplayGridlines = True

'why can't I just do this ?
ThisWorkbook.Sheets(1).DisplayGridlines = True
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
That's right. You will need to activate the Sheet for enabling or disabling the gridlines because Gridlines is the property of ActiveWindow.
Roy CoxGroup Finance ManagerCommented:
Unfortunately it will only work on the active sheet, try this. It hides the selection process

Dim oWs As Worksheet

    Set oWs = ActiveSheet ''/// determine the current active sheet
    Application.DisplayAlerts = False
    ActiveWindow.DisplayGridlines = Not ActiveWindow.DisplayGridlines ''/// toggle gridlines
    Application.ScreenUpdating = True

Open in new window

sidwelleAuthor Commented:
'this works
ThisWorkbook.Windows(1).DisplayGridlines = True

'but whats the difference between a 'window' and a 'sheet' ?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
ThisWorkbook.Windows(1) will always refer to the active sheet so it is equivalent to ActiveWindow.
Roy CoxGroup Finance ManagerCommented:
Not sure where I found it but it's from my list useful tips that I have compiled over the years

ActiveWindow Property

Returns a Window object that represents the active window (the window on top). Read-only. Returns Nothing if there are no windows open.

ActiveSheet Property

Returns an object that represents the active sheet (the sheet on top) in the active workbook or in the specified window or workbook. Returns Nothing if no sheet is active. Read-only.


If you don’t specify an object qualifier, this property returns the active sheet in the active workbook.
If a workbook appears in more than one window, the ActiveSheet property may be different in different windows.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sidwelleAuthor Commented:
Thank you,  I think I have enough to get it done.
Roy CoxGroup Finance ManagerCommented:
Pleased to help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.