ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Footer to All Sheets (https://www.excelbanter.com/excel-programming/404161-add-footer-all-sheets.html)

Mike H.

Add Footer to All Sheets
 
How do I add a footer to all sheets. This doesn't work because the
activesheet is not selected, I dont' think.

Sub AddFooters()
Dim WSheet As Worksheet
For Each WSheet In Worksheet
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&A"
.Zoom = False
End With
Next WSheet

End Sub

JE McGimpsey

Add Footer to All Sheets
 
One way:

Change

With ActiveSheet.PageSetup

to

With WSheet.PageSetup


In article ,
Mike H. wrote:

How do I add a footer to all sheets. This doesn't work because the
activesheet is not selected, I dont' think.

Sub AddFooters()
Dim WSheet As Worksheet
For Each WSheet In Worksheet
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&A"
.Zoom = False
End With
Next WSheet

End Sub


JLGWhiz

Add Footer to All Sheets
 
untried but should work.

Sub AddFooters()
Dim i As Long
For i = 1 To ActiveWorkbook.sheets.Count
With Sheets(i).PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&A"
.Zoom = False
End With
Next
End Sub

"Mike H." wrote:

How do I add a footer to all sheets. This doesn't work because the
activesheet is not selected, I dont' think.

Sub AddFooters()
Dim WSheet As Worksheet
For Each WSheet In Worksheet
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&A"
.Zoom = False
End With
Next WSheet

End Sub


Mike H.

Add Footer to All Sheets
 
That modification doesn't compile for me. I get a Variable not defined error
on the For statement?????

"JE McGimpsey" wrote:

One way:

Change

With ActiveSheet.PageSetup

to

With WSheet.PageSetup


In article ,
Mike H. wrote:

How do I add a footer to all sheets. This doesn't work because the
activesheet is not selected, I dont' think.

Sub AddFooters()
Dim WSheet As Worksheet
For Each WSheet In Worksheet
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&A"
.Zoom = False
End With
Next WSheet

End Sub



JE McGimpsey

Add Footer to All Sheets
 
Yeah - didn't look closely at that line - should be

For Each WSheet in Worksheets

or, more qualified:

For Each WSheet In ActiveWorkbook.Worksheets

In article ,
Mike H. wrote:

That modification doesn't compile for me. I get a Variable not defined error
on the For statement?????

"JE McGimpsey" wrote:

One way:

Change

With ActiveSheet.PageSetup

to

With WSheet.PageSetup


In article ,
Mike H. wrote:

How do I add a footer to all sheets. This doesn't work because the
activesheet is not selected, I dont' think.

Sub AddFooters()
Dim WSheet As Worksheet
For Each WSheet In Worksheet
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&A"
.Zoom = False
End With
Next WSheet

End Sub




All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com