Active Hedings without ActiveWindow cmd

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
172
Office Version
  1. 2016
Platform
  1. Windows
Hi

Is there away to display all headings without using Active Window.
The following code works fine but i don't want to open and activate each sheet just to turn on Headings, as this triggers other objects like WS_Actvate etc.

Code:
            For Each ws In Sheets
                ws.Visible = xlSheetVisible
                ws.Activate
                With ActiveWindow
                    .DisplayHeadings = True
                    ' more
                End With
            Next ws

Cheers Paul
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,882
Office Version
  1. 365
Platform
  1. Windows
Couldn't you just put that command into each sheet's _Activate event, so that it only fires when the sheet's actually opened?
Code:
Private Sub Worksheet_Activate()
ActiveWindow.DisplayHeadings = True
End Sub
 

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
172
Office Version
  1. 2016
Platform
  1. Windows
Thanks for suggestion.
the above is within an if as not all sheets have headings n in every state of view...
Plus i still have the problem of how to switch off again when sheet is not active
:(
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,882
Office Version
  1. 365
Platform
  1. Windows
Plus i still have the problem of how to switch off again when sheet is not active
:(
Just use the sheet's _deactivate event...
Code:
Private Sub Worksheet_Deactivate()
ActiveWindow.DisplayHeadings = False
End Sub
 

Forum statistics

Threads
1,141,707
Messages
5,707,985
Members
421,539
Latest member
zuniBM

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
Top