Auto footers on multiple pages

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
 
B

Bob Umlas

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
 
D

DTTODGG

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?
 
D

Dave Peterson

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
 
D

DTTODGG

Thank you Bob and Dave.
I can build off of and learn more about excel thru this simple macro.
 
J

JLGWhiz

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
 

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

Top