Can you create a dynamic footer in Excel?

M

mge

I would like to include a footer that reads from the sheet being printed.
Does anyone know of a practical way to do this?
 
M

mge

I was able to come up with code that does this. See Below:

This code goes in the VBAProject Workbook section

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim Wks As Worksheet
Dim stFullFileName As String
Dim stCompanyName As String

stCompanyName = Worksheets("Sheet1").Range("G19").Value
stFullFileName = ThisWorkbook.FullName
For Each Wks In ThisWorkbook.Worksheets
With Wks.PageSetup
.LeftFooter = stCompanyName
.CenterFooter = ""
.RightFooter = ""
End With
Next Wks

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