How to set footer and header for all sheets?

  • Thread starter Thread starter Kurt Remlin
  • Start date Start date
K

Kurt Remlin

Hi,

I'm creating a brand new workbook with multiple sheets from VB code.
How do I programmatically assign Sheet Name as a header and 'Page 1 of
?' as a footer to all of them? Please advise.

TIA
 
Kurt

Select the first sheet by clicking on the tab; select the rest of the sheets
by shift clicking on the last tab.

Now select View | Header and Footer... | Header/Footer tab | modify the
header and footer as required.

If you add the tab name to the header and page information to the footer it
will be applied to all the selected sheets

Regards

Trevor
 
Sub tester()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws.PageSetup
.LeftHeader = "&A"
.LeftFooter = "Page &P of &N"
End With
Next ws
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top