I have a file that has multiple worksheets with some of the worksheets visible and some of the worksheets hidden. I want a macro to run only on the visible worksheets and to ignore the hidden worksheets. The macro below is supposed to create a header on all the sheets in the workbook that combines the file name with information from cell C1 of the tab titled Productivity and then add the worksheet name on a new line. Right now my macro runs on all the sheets in my workbooks, both visible and hidden, but I only want it to run on visible sheets. Any help would be appreciated.


Sub Workbook_BeforePrint()
Dim ws As Worksheet, wsT As Worksheet
Set wsT = Sheets("Productivity")
For Each ws In Worksheets
ws.PageSetup.CenterHeader = "&f " & wsT.Range("C1").Value & Chr(13) & "&a"
Next ws
End Sub