Add/not replace footer

G

Guest

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

Dave O

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
 

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