ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Add/not replace footer (https://www.excelbanter.com/excel-discussion-misc-queries/106632-add-not-replace-footer.html)

Steve

Add/not replace footer
 
Is it possible to use VBA code to scroll through the sheets in a workbook and
if there's a center footer, add a CRLF and then some text. If there is not
footer, just add the text. I use code to set footers but when I do something
like this:

Dim Sh As Worksheet
For Each Sh In Worksheets
With Sh.PageSetup
.CenterFooter = "Some text" & Chr(10) & "Some more text"
...

I get the footers replaced. I want it added to what's already there. Thanks.

Dave O

Add/not replace footer
 
If I read your post correctly, this code should do it. If a footer
exists already, then this code adds to it. Note this Usenet interface
word wraps, so you may need to revise the line breaks.

Sub Append_Footer()
Dim Sh As Worksheet

For Each Sh In Sheets
With Sh.PageSetup
If .CenterFooter < "" Then .CenterFooter = .CenterFooter & " " &
Chr(10) & "Some more text"
End With
Next Sh

End Sub



All times are GMT +1. The time now is 03:01 PM.

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