Auto footers on multiple pages

  • Thread starter Thread starter DTTODGG
  • Start date Start date
D

DTTODGG

Hello,

I'm trying to have a macro that will automatically print the file name, tab,
and date at the bottom of each page in each sheet in the workbook.

Thanks in advance for your help!


Dim wksht As Worksheet

For Each wksht In Worksheet

With ActiveSheet.PageSetup
.LeftFooter = "&6&F &A &D"
.FooterMargin = Application.InchesToPoints(0.25)
Next
End Sub
 
Change to:

Dim wksht As Worksheet

For Each wksht In Worksheet

With wksht.PageSetup '<====error was here
.LeftFooter = "&6&F &A &D"
.FooterMargin = Application.InchesToPoints(0.25)
Next
End Sub
 
Thanks Bob, that makes sense. I'm really new to this and need every detail
explained.

Does the For/Next require something?
I'm getting an error. I don't know how many sheets there might be.
So, do I need to activate a sheet before the next loop?
 
You have another typo:

Dim wksht As Worksheet

For Each wksht In Worksheets '<--added S to worksheet
With wksht.PageSetup '<-- same correction as Bob showed.
.LeftFooter = "&6&F &A &D"
.FooterMargin = Application.InchesToPoints(0.25)
Next wksht '<-- wksht not required, but I like it!
End Sub
 
Thank you Bob and Dave.
I can build off of and learn more about excel thru this simple macro.
 
This should work:

Dim wksht As Worksheet
For Each wksht In ThisWorkbook.Worksheets
With wksht.PageSetup
.LeftFooter = "&6&F &A &D"
.FooterMargin = Application.InchesToPoints(0.25)
End With
Next
End Sub
 
Back
Top